File tree Expand file tree Collapse file tree 2 files changed +22
-22
lines changed
프로그래머스/1/17681. [1차] 비밀지도 Expand file tree Collapse file tree 2 files changed +22
-22
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 73.6 MB, 시간: 7.75 ms
7+ 메모리: 72.3 MB, 시간: 5.82 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2024년 03월 08일 13:15:00
19+ 2025년 10월 10일 20:25:56
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 1- import java .util .*;
21class Solution {
32 public String [] solution (int n , int [] arr1 , int [] arr2 ) {
4- String [] answer = {};
5- answer = new String [n ];
3+ String [] answer = new String [n ];
64
7- for (int i =0 ; i <n ; i ++)
8- {
9- String str ="" ;
10- String str1 = String .format ("%" + n + "s" , Integer .toBinaryString (arr1 [i ])).replace (' ' , '0' );
11- // 두 번째 배열의 이진 문자열 생성
12- String str2 = String .format ("%" + n + "s" , Integer .toBinaryString (arr2 [i ])).replace (' ' , '0' );
13-
14- for (int j =0 ; j <n ; j ++)
15- {
16- if (str1 .charAt (j )=='1' || str2 .charAt (j )=='1' )
17- {
18- str +="#" ;
5+ int arr [][] = new int [n ][n ];
6+
7+ for (int i =0 ; i <n ; i ++) {
8+ String binary1 = addZero (Integer .toBinaryString (arr1 [i ]), n );
9+ String binary2 = addZero (Integer .toBinaryString (arr2 [i ]), n );
10+ String answer2 = "" ;
11+ for (int j =0 ; j <n ; j ++) {
12+ if (binary1 .charAt (j ) == '1' || binary2 .charAt (j ) == '1' ) {
13+ answer2 = answer2 +"#" ;
1914 }
20- else
21- {
22- str +=" " ;
15+ else {
16+ answer2 = answer2 +" " ;
2317 }
2418 }
25- answer [i ]= str ;
19+ answer [i ] = answer2 ;
2620 }
2721 return answer ;
28-
22+ }
23+
24+ public String addZero (String str , int n ) {
25+ while (str .length () != n ) {
26+ str = "0" + str ;
27+ }
28+ return str ;
2929 }
3030}
You can’t perform that action at this time.
0 commit comments