[Swift] 덧칠하기

물복딱복준복
|2023. 4. 15. 00:08
import Foundation

func solution(_ n:Int, _ m:Int, _ section:[Int]) -> Int {
    
    var paint = section[0] - 1
    var count = 0
    
    section.forEach {
        if paint < $0 {
            paint = $0 + m - 1
            count += 1
        }
    }
    
    return count

}

'프로그래머스 > Lv.1' 카테고리의 다른 글

[Swift] 공원 산책  (0) 2023.04.25
[Swift] 달리기 경주  (0) 2023.04.25
[Swift] 카드뭉치  (0) 2023.04.14
[Swift] 추억점수  (0) 2023.04.14
[Swift] X만큼 간격이 있는 N개의 숫자  (0) 2023.02.27