class Solution {
fun solution(wallpaper: Array<String>): IntArray {
val answer = intArrayOf(wallpaper.size, wallpaper[0].length, 0, 0)
wallpaper.forEachIndexed { rowIndex, rowItem ->
rowItem.forEachIndexed { columnIndex, columnItem ->
if (columnItem == '#') {
answer[0] = answer[0].coerceAtMost(rowIndex)
answer[1] = answer[1].coerceAtMost(columnIndex)
answer[2] = answer[2].coerceAtLeast(rowIndex + 1)
answer[3] = answer[3].coerceAtLeast(columnIndex + 1)
}
}
}
return answer
}
}
이 글은 제게 많은 도움이 되었습니다.