[LeetCode] 274. H-Index

夜歌乘年少發表於2024-07-05

意外的簡單。

class Solution:
    def hIndex(self, citations: List[int]) -> int:
        sorted_list = sorted(citations, reverse=True)
        ret = 0
        for i,element in enumerate(sorted_list[:1000]):
            curr = min(i+1, element)
            if curr > ret:
                ret = curr
        return ret

image