1 class Solution:
 2     def hIndex(self, citations: 'List[int]') -> int:
 3         n = len(citations)
 4         if n == 0:
 5             return 0
 6         citations = sorted(citations,reverse=True)
 7         
 8         for i in range(n):
 9             if i+1 >= citations[i]:
10                 return max(citations[i],i)
11         nonZero = 0
12         for i in range(n):
13             if citations[i] != 0:
14                 nonZero += 1
15         return nonZero

这题目如果对h-index不是特别清楚的话,光看题目的描述,对题目的要求是很难理解清楚的。

难怪给了800多个差评。

应该多给一些有代表性的例子。

posted on 2020-04-06 08:41  Sempron2800+  阅读(101)  评论(0编辑  收藏  举报