[Swift 알고리즘] 기능개발

장주명·2021년 5월 16일
0
func solution(_ progresses:[Int], _ speeds:[Int]) -> [Int] {
    var minmumDay = 0
    var countOfDay : [Int] = []
    for i in 0..<progresses.count {
        let progresse = Double(progresses[i])
        let speed = Double(speeds[i])
        let day = Int(ceil((100-progresse)/speed))
        if day > minmumDay {
            minmumDay = day
            countOfDay.append(1)
        } else {
            countOfDay[countOfDay.count - 1] += 1
        }
    }
    return  countOfDay
}
profile
flutter & ios 개발자

0개의 댓글

Powered by GraphCDN, the GraphQL CDN