Algorithm/프로그래머스
[프로그래머스] H-Index - 파이썬
potato_pizza
2024. 6. 19. 11:54
728x90
H-Index
https://school.programmers.co.kr/learn/courses/30/lessons/42747
문제
코드
- citations 리스트를 내림차순으로 정렬
- 루프를 돌면서 현재 인용횟수(i)가 현재의 h_index보다 크거나 같으면 h_index 값을 +1
def solution(citations):
citations.sort(reverse=True)
h_index = 0
for i in citations:
if i > h_index:
h_index += 1
return h_index
728x90
반응형