문제링크 : 코딩테스트 연습 - H-Index | 프로그래머스 (programmers.co.kr)

풀이 방법
정렬을 하고 본문에 나온 문제대로 풀면 된다.
문제 자체를 이해하고 추상화하는 과정이 오래걸린다.
나의 풀이
풀이 확인
def solution(citations):
answer = 0
citations = sorted(citations, reverse=True)
for i in range(len(citations)):
if citations[i] > answer:
answer += 1
else:
return answer
return answer다른 사람 풀이
풀이 확인
def solution(citations):
citations = sorted(citations)
l = len(citations)
for i in range(l):
if citations[i] >= l-i:
return l-i
return 0def solution(citations):
citations.sort(reverse=True)
answer = max(map(min, enumerate(citations, start=1)))
return answer밑의 풀이는 그냥 미쳤다고 밖에 설명이 안된다...
'알고리즘 > problem solving' 카테고리의 다른 글
| [프로그래머스] level2 스킬트리 (0) | 2021.04.16 |
|---|---|
| [프로그래머스] level2 완전탐색 카펫 (0) | 2021.04.15 |
| [프로그래머스] level2 완전탐색 소수찾기 (0) | 2021.04.15 |
| [프로그래머스] level2 힙 더 맵게 (0) | 2021.04.14 |
| [프로그래머스] level 2 정렬 - 가장 큰 수 (0) | 2021.04.14 |