-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlessons_161990.java
More file actions
31 lines (25 loc) · 857 Bytes
/
lessons_161990.java
File metadata and controls
31 lines (25 loc) · 857 Bytes
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
/*
바탕화면 정리
https://school.programmers.co.kr/learn/courses/30/lessons/161990
*/
class Solution {
public int[] solution(String[] wallpaper) {
int n = wallpaper.length;
int m = wallpaper[0].length();
int minX = Integer.MAX_VALUE;
int minY = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int maxY = Integer.MIN_VALUE;
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
if ('#' == wallpaper[i].charAt(j)) {
minX = Math.min(minX, i);
minY = Math.min(minY, j);
maxX = Math.max(maxX, i);
maxY = Math.max(maxY, j);
}
}
}
return new int[]{ minX, minY, maxX+1, maxY+1 };
}
}