import Foundation

func solution(_ n:Int, _ m:Int, _ section:[Int]) -> Int {
    var list = section
    var count = 0
    while !list.isEmpty {
        let removed = list.removeFirst()
        while !list.isEmpty && list.first! - removed < m {
            list.removeFirst()
        }
        count += 1
    }
    return count
}
ytw_developer