1 def hIndex(citations): 2 citations.sort() 3 n = len(citations) 4 index = 0 5 while index < n: 6 if n - index <= citations[index]: 7 break 8 index += 1 9 return n - index
1 def hIndex(citations): 2 citations += [0] # 加个哨兵 3 print(citations) 4 citations.sort(reverse=True) # 降序排列 5 for i, c in enumerate(citations): 6 if i + 1 > c: 7 return i
标签:sort,index,指数,hIndex,citations,274,def From: https://www.cnblogs.com/wanxueyu/p/16768088.html