public int[] solution(String[] wallpaper) {
int minRow = Integer.MAX_VALUE;
int minCol = Integer.MAX_VALUE;
int maxRow = Integer.MIN_VALUE;
int maxCol = Integer.MIN_VALUE;
int row = wallpaper.length;
int col = wallpaper[0].length();
for (int r = 0; r < row; r++) {
for (int c = 0; c < col; c++) {
if (wallpaper[r].charAt(c) == '#') {
minRow = Math.min(minRow, r);
minCol = Math.min(minCol, c);
maxRow = Math.max(maxRow, r);
maxCol = Math.max(maxCol, c);
}
}
}
return new int[] { minRow, minCol, maxRow + 1, maxCol + 1 };
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/161990