首页 > 其他 > 详细

leetcode274

时间:2020-04-06 10:04:36      阅读:55      评论:0      收藏:0      [点我收藏+]
 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多个差评。

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

leetcode274

原文:https://www.cnblogs.com/asenyang/p/12640530.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!