[Programmers] H-Index (Python)
SolutionPermalink
from typing import List
def solution(citations: List[int]) -> int:
N = len(citations)
# hμ μ΅λκ°
answer = 0
citations.sort()
for i, citation in enumerate(citations):
# μ μμ H-μ§μλ κ·Έλ€μ NνΈμ λ
Όλ¬Έ μ€ hνΈμ΄ μ μ΄λ hλ² μΈμ©λμκ³ ,
# λλ¨Έμ§ (N β h)νΈμ λ
Όλ¬Έμ΄ hλ²μ μ΄κ³Όνμ§ μκ² μΈμ©λμμ λμ h κ°μ κ°μ§
if citation >= N - i:
answer = N - i
break
return answer
print(solution([3, 0, 6, 1, 5]))
Leave a comment