public int[] solution(int brown, int yellow) {
int[] answer = new int[2];
int area = brown + yellow;
for (int row = 1; row <= area; row++) {
int col = area / row;
if (row > col) {
continue;
}
if ((row - 2) * (col - 2) == yellow) {
answer[0] = col;
answer[1] = row;
return answer;
}
}
return answer;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/42842