[프로그래머스] 바탕화면 정리(Kotlin)

0

프로그래머스

목록 보기
108/128
post-thumbnail
post-custom-banner

[프로그래머스] 바탕화면 정리(Kotlin)

풀이

import kotlin.math.*

class Solution {
    fun solution(wallpaper: Array<String>): IntArray {
        var minLx = 100
        var minLy = 100
        var maxRx = -100
        var maxRy = -100
        
        for(y in 0 until wallpaper.size){
            for(x in 0 until wallpaper[y].length){
                if(wallpaper[y][x] == '#'){
                    minLx = min(minLx, x)
                    minLy = min(minLy, y)
                    maxRx = max(maxRx, x+1)
                    maxRy = max(maxRy, y+1)
                }
            }
        }
        
        return intArrayOf( minLy,minLx, maxRy, maxRx)
    }
}
profile
Be able to be vulnerable, in search of truth
post-custom-banner

0개의 댓글