문제
(프로그래머스) 실패율
Python 풀이
def solution(N, stages):
backup = {}
len_stages = len(stages)
for i in range(1, N + 1):
if len_stages != 0:
same_nums = stages.count(i)
backup[i] = same_nums / len_stages
len_stages -= same_nums
else:
backup[i] = 0
new_backup = sorted(backup.items(), key = lambda x : - x[1])
results = []
for j in range(N):
results.append(new_backup[j][0])
return results