문제: https://school.programmers.co.kr/learn/courses/30/lessons/42747
처음에 풀때 테스트9번이 실패했는데 [4, 4, 4] 일 경우를 생각해보면 된다
def solution(citations):
answer = 0
citations = sorted(citations,reverse=True)
for index,i in enumerate(citations):
if i < (index + 1):
answer = index
break
if citations[-1] > len(citations):
answer = len(citations)
return answer
반응형
'공부 서랍장 > 알고리즘 공부' 카테고리의 다른 글
[알고리즘 필수 기법] 조합, 순열 (0) | 2022.09.18 |
---|---|
[프로그래머스] 모음사전 python (0) | 2022.09.18 |
[프로그래머스] 성격 유형 검사하기 python (0) | 2022.09.18 |
[프로그래머스] 신고 결과 받기 python (0) | 2022.09.18 |
[프로그래머스] 이상한 문자 만들기 python (0) | 2022.09.17 |