paperCounts
with a size of n + 1
to count the number of papers for each citation number, where n
is the length of the input citations
array.citations
array, and for each citation count, increment the corresponding index in the paperCounts
array. If the citation count is larger than n
, increment the last index of paperCounts
.totalPapers
to keep track of the cumulative sum of papers from the end of the paperCounts
array.paperCounts
array in reverse. For each index i
, add the count at paperCounts[i]
to totalPapers
.totalPapers
becomes greater than or equal to the index i
, return i
as the h-index.