[Programmers] - 기능개발 (Level 2)


스택/큐
LEVEL : 2
문제링크

progresses = [95, 90, 99, 99, 80, 99]
speeds = [1,1,1,1,1,1]
def solution(progresses, speeds):

    import math
    answer = []
    timecost = [math.ceil((100-progresses[i])/speeds[i]) for i in range(len(speeds))]

    start = 0
    tmp = 1
    t = 1
    while start+t<len(timecost):

        if timecost[start]<timecost[start+t]:
            answer.append(tmp)
            start += t
            tmp = 1
            t = 1

        else:
            tmp+=1
            t+=1

    answer.append(tmp)

    return answer
solution(progresses, speeds)
[1, 3, 2]

Comments