기능개발 - python (programmers)

참치돌고래·2021년 5월 18일
0

알고리즘

목록 보기
6/36
post-custom-banner

스택/큐 level2

기능개발

-->https://programmers.co.kr/learn/courses/30/lessons/42586

def solution(progresses, speeds):
    answer = []
    stack = []
    cnt = 0 
    for progress in progresses[::-1]:
        stack.append(progress)
    
    speeds = speeds[::-1]
    
    while stack:
        cnt = 0
        for i in range(len(stack)):
            stack[i] +=speeds[i]
        
        length= len(stack)
        
        for i in range(length):
            if stack[-1]>=100:
                stack.pop()
                speeds.pop()
                cnt+=1
        
        if cnt!=0:
            answer.append(cnt)
    
    return answer
profile
안녕하세요
post-custom-banner

0개의 댓글