Problem
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher’s h-index.
According to the definition of h-index on Wikipedia: The h-index is defined as the maximum value of h such that the given researcher has published at least h papers that have each been cited at least h times.文章来源:https://www.toymoban.com/news/detail-598672.html
Algorithm
Sort the citations by the reverse order and calculate the h-index.文章来源地址https://www.toymoban.com/news/detail-598672.html
Code
class Solution:
def hIndex(self, citations: List[int]) -> int:
clen = len(citations)
citations.sort(reverse = True)
n = 0
while n < clen and citations[n] >= n+1:
n += 1
return n
到了这里,关于Leetcode 274. H-Index的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!