[LeetCode] 274. H-Index

意外的简单。

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

posted @ 2024-07-05 00:46  夜歌乘年少  阅读(8)  评论(0编辑  收藏  举报