[Python] 프로그래머스 - Level2 - 기능개발

강주형·2022년 8월 20일
0

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

스택/큐

def solution(progresses, speeds):
    rest = []
    result = []
    for p, s in zip(progresses, speeds):
        if (100 - p) / s == (100 - p) // s:
            x = ((100 - p) // s)
        else:
            x = ((100 - p) // s + 1)
        if rest:
            if rest[-1] >= x:
                result[-1] += 1
            else:
                result.append(1)
                rest.append(x)
        else:
            result.append(1)
            rest.append(x)
    return result

타인 코드
def solution(progresses, speeds):
    Q=[]
    for p, s in zip(progresses, speeds):
        if len(Q)==0 or Q[-1][0]<-((p-100)//s):
            Q.append([-((p-100)//s),1])
        else:
            Q[-1][1]+=1
    return [q[1] for q in Q]

뭔소린지 모르겠다.
다시 보기

profile
Statistics & Data Science

0개의 댓글