H-Index

You are given an array `citations` where `citations[i]` is how many times a researcher's i-th paper has been cited. Return the researcher's h-index: the largest h such that the researcher has at least h papers that were each cited at least h times.

30:00

H-Index
medium
Free written solution
Topics
Companies

You are given an array citations where citations[i] is how many times a researcher's i-th paper has been cited. Return the researcher's h-index: the largest h such that the researcher has at least h papers that were each cited at least h times.

Example 1:
Input: {"citations":[3,0,6,1,5]}
Output: 3
Constraints:
  • n==citations.lengthn == \text{citations.length}

  • 1≤n≤50001 \leq n \leq 5000

  • 0≤citations[i]≤10000 \leq \text{citations}[i] \leq 1000

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"citations":[3,0,6,1,5]}

n

5

candidate h

-

citations[i]

-

h-index

?

Papers in input order

3001621354

5 papers, one bar each. We want the largest h with at least h bars reaching height h.

Variables
VariableValue
n5
DepthFunction Call
Stack empty
0/9