반응형
def solution(N, stages):
len_stages = len(stages)
check_arr = {}
count_stages = { stage: 0 for stage in stages }
for stage in stages:
count_stages[stage] += 1
for idx in range(1, N+1):
if idx in count_stages.keys():
check_arr[idx] = (count_stages[idx] / len_stages) * 100
len_stages = len_stages - count_stages[idx]
else:
check_arr[idx] = 0
return sorted(check_arr, key=lambda x: check_arr[x], reverse=True)
반응형
'삽집하는 개발들 > 알고리즘' 카테고리의 다른 글
[47일차][Lv1][프로그래머스][120869]외계어 사전 (4) | 2023.08.24 |
---|---|
[46일차][프로그래머스][136798]기사단원의 무기 (2) | 2023.08.22 |
[45일차][프로그래머스][161989]덧칠하기 (0) | 2023.08.22 |
[44일차][프로그래머스][12921]소수 찾기 (4) | 2023.08.19 |
[43일차][프로그래머스][Summer/Winter Coding(~2018)][12977]소수 만들기 (0) | 2023.08.11 |