H-Index

Given an array of citation counts, return the H-index, defined by the largest h such that at least h papers have at least h citations each. Sorting the bounded counts makes the threshold easy to check.

Input Format

citations = array of paper citation counts

Output Format

H-index value

Constraints

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

Examples

Example 1:

Input:

citations = [3,0,6,1,5]

Output:

3

Explanation:

There are three papers with at least three citations.

Example 2:

Input:

citations = [1,3,1]

Output:

1

Explanation:

At least one paper has at least one citation.

Loading...
H-Index - Sorting Based Array Problems