티스토리 뷰
programmers.co.kr/learn/courses/30/lessons/42889
def solution(N, stages):
answer = []
s = {}
stages = sorted(stages)
for n in range(1, N+1):
s[n] = 0
user = len(stages)
prev = 1
for i in range(1, N+1):
if i >= prev and user != 0:
cnt = stages.count(i)
s[i] = cnt / user
prev += 1
user -= cnt
s = sorted(s.items(), key = lambda x: x[1], reverse = True)
for key in s:
answer.append(key[0])
return answer
'Algorithm > Programmers' 카테고리의 다른 글
[프로그래머스] 키패드 누르기 - Python (0) | 2021.03.30 |
---|---|
[프로그래머스] 더 맵게 - Python (0) | 2021.03.30 |
[프로그래머스] 오픈채팅방 - Python (0) | 2021.03.27 |
[프로그래머스] 기능개발 - Python (0) | 2021.03.26 |
[프로그래머스] 튜플 - Python (0) | 2021.03.25 |