컴공생의 다이어리
[프로그래머스] 실패율 - 파이썬(Python) 본문
[프로그래머스] 실패율 - 파이썬(Python)
import collections
def solution(N, stages):
total_people = len(stages)
stage_count = dict(collections.Counter(stages))
result = []
for i in range(1, N + 1):
if i in stage_count.keys():
result.append((i, stage_count[i] / total_people))
total_people -= stage_count[i]
else:
result.append((i, 0))
result.sort(key=lambda x: (-x[1], x[0]))
return [x for x, _ in result]
https://programmers.co.kr/learn/courses/30/lessons/42889
코딩테스트 연습 - 실패율
실패율 슈퍼 게임 개발자 오렐리는 큰 고민에 빠졌다. 그녀가 만든 프랜즈 오천성이 대성공을 거뒀지만, 요즘 신규 사용자의 수가 급감한 것이다. 원인은 신규 사용자와 기존 사용자 사이에 스
programmers.co.kr
728x90
'Development > Algorithm & Coding Test' 카테고리의 다른 글
[프로그래머스] 캐시 - 파이썬(Python) (0) | 2022.06.14 |
---|---|
[프로그래머스] 후보키 - 파이썬(Python) (0) | 2022.06.13 |
[프로그래머스] 오픈채팅방 - 파이썬(Python) (0) | 2022.06.11 |
[프로그래머스] 방문 길이 - 파이썬(Python) (0) | 2022.06.09 |
[프로그래머스] 더 맵게 - 파이썬(Python) (0) | 2022.06.08 |
Comments