알고리즘

[프로그래머스] 실패율

HHB 2023. 10. 7. 18:52
def solution(N, stages):
    answer = {}
    fail = len(stages)
    for i in range(1, N+1):
        cnt = 0
        if stages.count(i) > 0:
            cnt += stages.count(i)
            answer[i] = cnt/fail
            fail-=cnt
        else:
            answer[i] = 0

    return sorted(answer, key=lambda x : answer[x], reverse=True)
728x90
반응형
LIST