Deep_Dev

https://school.programmers.co.kr/learn/courses/30/lessons/17681

 

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.

programmers.co.kr

 


 

 

 

class Solution {
    public String[] solution(int n, int[] arr1, int[] arr2) {
         String[] answer = new String[n];

        for(int i=0; i<n; i++){
            // or์—ฐ์‚ฐ -> ํ•˜๋‚˜๋ผ๋„ ๋ฒฝ('1')์ธ ๊ฒฝ์šฐ 1์ €์žฅ
            answer[i]=Integer.toBinaryString(arr1[i] | arr2[i]);
            answer[i]=answer[i].replace('0',' ');
            answer[i]=answer[i].replace('1','#');
            // ์ž๋ฆฟ์ˆ˜๋งž์ถ”๊ธฐ (ex: ์ด์ง„์ˆ˜ ๋ณ€ํ™˜์‹œ 1์€ 00001์ด ์•„๋‹Œ 1์ด๋‹ค. )
            while(answer[i].length()<n){
                answer[i]=' '+answer[i];
            }
        }
        return answer;
    }
}