Skip to content

H-Index

MediumArrays & Hashing
Decode it first. Clues, constraints, pattern and plan before any code.

A researcher has published n papers, and citations[i] says how many times paper i has been cited. Their h-index is the largest number h such that at least h papers have h or more citations each. Return it.

citations = [4, 0, 7, 2, 5]   →  3   (4, 7 and 5 each have at least 3)
citations = [2, 9, 2]         →  2
citations = [0, 0]            →  0

Constraints

  • 1 <= citations.length <= 5000
  • 0 <= citations[i] <= 1000