class Solution { //substring
fun solution(progresses: IntArray, speeds: IntArray): IntArray {
var answer = IntArray(progresses.size)
var index = 0
var lenght = 0
while(lenght < progresses.size){ //모든 작업이 끝날 때 까지
for (index_ in speeds.indices){ // 일단 시간 다 더해
progresses[index_] += speeds[index_]
}
var number = 0
for (num in lenght..progresses.size - 1){ // 100 넘어가면 끝이니까
if (progresses[num] >= 100) ++number
else break //100 안넘으면 뒤에꺼 넘어도 못 빼니 그만
}
if(number > 0){ // 100넘은게 있으면 실행 빼야 하니까
answer[index++] = number
lenght += number
}
}
return answer.sliceArray(0..index - 1) // 마지막에 index++ 되면서 끝나니까 1 빼줌
}
}
하.. IntArray() 이거랑 intarrayOf() 이거랑 같은건줄 알고 계속 index오류나서 화났었네,, vscode로 디버깅 어떻게 하는건지좀 알아내야지
[Kotlin] 카펫 (0) | 2021.04.28 |
---|---|
[Python] 프린터 (0) | 2021.04.20 |
[Kotlin] 키패드 누르기 (0) | 2021.04.18 |
[Python] 실패율 (0) | 2021.04.16 |
[Python] [Kotlin]프로그래머스 - 내적 (0) | 2021.04.14 |
댓글 영역