ํฐ์คํ ๋ฆฌ ๋ทฐ
[๋ฌธ์ ]
https://school.programmers.co.kr/learn/courses/30/lessons/17681
[ํ์ด]
์ฐ์ arr1[]๊ณผ arr2[]์ ์ซ์๋ค์ binaryNumber()์ ํตํด 2์ง์์ String ๋ณ์๋ก ๋ณํํฉ๋๋ค.
๋ค์์ผ๋ก ํด๋น String๋ณ์๋ฅผ split()์ ํตํด bit๋ก ์ชผ๊ฐ ํ, || ์ฐ์ฐ์ ํตํด ๋์ค 1๊ฐ๊ฐ 1์ด๋ผ๋ฉด #์ ์ ์ฅํฉ๋๋ค.
[์ฝ๋]
class Solution {
public String[] solution(int n, int[] arr1, int[] arr2) {
String[] answer = new String[n];
for(int i=0;i<n;i++) {
String[] s1 = binaryNumber(arr1[i], n).split("");
String[] s2 = binaryNumber(arr2[i], n).split("");
String result = "";
for(int j=0;j<n;j++) {
if(s1[j].equals("1") || s2[j].equals("1")) {
result += "#";
} else {
result += " ";
}
}
answer[i] = result;
}
return answer;
}
public static String binaryNumber(int num, int n) {
String str = "";
while(num > 0) {
if(num%2 == 0) {
str = 0 + str;
} else {
str = 1 + str;
}
num /= 2;
}
int len = str.length();
if(len < n) {
for(int i=0;i<n-len;i++) {
str = 0 + str;
}
}
return str;
}
}
'Algorithm > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Java] ํ๋ก๊ทธ๋๋จธ์ค - ์บ์ (0) | 2022.07.07 |
---|---|
[Java] ํ๋ก๊ทธ๋๋จธ์ค - ๋๊ตด ํํ (0) | 2022.07.07 |
[Java] ํ๋ก๊ทธ๋๋จธ์ค - ๋ณด์ ์ผํ (0) | 2022.07.03 |
[Java] ํ๋ก๊ทธ๋๋จธ์ค - ์์ ์ต๋ํ (0) | 2022.07.03 |
[Java] ํ๋ก๊ทธ๋๋จธ์ค - ํคํจ๋ ๋๋ฅด๊ธฐ (0) | 2022.07.03 |
๊ณต์ง์ฌํญ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
- Total
- Today
- Yesterday
๋งํฌ
TAG
- map
- ๋ฐฑ์ค javascript
- ์๋ฐ์คํฌ๋ฆฝํธ
- ์๋ฐ
- ์๊ณ ๋ฆฌ์ฆ
- ๋ฐฑ์ค node.js
- ๋คํธ์ํฌ
- fp
- ๋ ์์ปฌ ํ๊ฒฝ
- Baekjoon
- 2019 ์นด์นด์ค ๊ฐ๋ฐ์ ๊ฒจ์ธ ์ธํด
- ์นด์นด์ค ์ธํด
- ํ๋กํผํฐ
- ์ด๋ถํ์
- ํ๋ก๊ทธ๋๋จธ์ค
- ๊ฐ์ฒด์งํฅ ํ๋ก๊ทธ๋๋ฐ
- ์ฝ๋ฉํ ์คํธ
- ์ด์์ฒด์
- ์ ์ญ ๋ณ์
- ๋ค์ด๋๋ฏน ํ๋ก๊ทธ๋๋ฐ
- ํ๋กํ ์ฝ
- git
- ๋์์ธ ํจํด
- ํฌํฌ์ธํฐ
- ํจ์ํ ํ๋ก๊ทธ๋๋ฐ
- TDD
- ๋ชจ๋ ์๋ฐ์คํฌ๋ฆฝํธ deep dive
- ๋ฐฑ์ค
- JavaScript
- http
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
๊ธ ๋ณด๊ดํจ