Editor

A Researcher's H-Index

#265 · Sorting and searching · Intermediate · 60 XP · about 10 min

Scientists are sometimes judged by their h-index. citations[i] is how many times paper i has been cited by other papers. The h-index is the largest number h such that the researcher has at least h papers that were each cited at least h times.

Write h_index(citations) that returns the h-index as an integer. A researcher with no papers, or with no cited papers, has an h-index of 0.

Examples

h_index([6, 0, 3, 5, 1])    # returns 3
h_index([10, 10, 10])       # returns 3
h_index([0, 0])             # returns 0
h_index([25, 8, 5, 3, 3])   # returns 3

In the first example three papers (cited 6, 5 and 3 times) have at least 3 citations each, but there are not four papers with at least 4 citations each. In the last example one famous paper does not help: there are only three papers with 3 or more citations.

Constraints

  • 0 <= len(citations) <= 100,000
  • 0 <= citations[i] <= 10^9

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.