비트연산으로 푸는 문제.
#include <string>
#include <vector>
using namespace std;
vector<string> solution(int n, vector<int> arr1, vector<int> arr2) {
vector<string> answer;
for (int i = 0; i < n; i++)
{
string in = "";
int temp = arr1[i] | arr2[i];
int mod = 1 << n - 1;
for (int j = 1; j <= n; j++)
{
if (temp & mod)
in += '#';
else
in += ' ';
mod = mod >> 1;
}
answer.push_back(in);
}
return answer;
}'Coding_Test 연습 > Programmers' 카테고리의 다른 글
| [프로그래머스] (C++) LV1 다트 게임 (0) | 2022.04.25 |
|---|---|
| [프로그래머스] (C++) LV1 가운데 글자 가져오기 (0) | 2022.04.25 |
| [프로그래머스] (C++) LV1 부족한 금액 계산하기 (0) | 2022.04.25 |
| [프로그래머스] (C++) LV1 나머지가 1이 되는 수 찾기 (0) | 2022.04.25 |
| [프로그래머스] (C++) LV1 최소직사각형 (0) | 2022.04.25 |