Description

Given citations array, return the researcher's h-index: the maximum h such that h papers have at least h citations each.

Examples

Input:citations = [3,0,6,1,5]
Output:3
Explanation:

3 papers with ≥3 citations.

Input:citations = [10,10,10,10,10]
Output:5
Explanation:

All 5 papers have at least 5 citations, but it is possible to't have more than 5 papers with at least 6 citations since there are only 5 papers total. Therefore, h-index is 5.

Input:citations = [100]
Output:1
Explanation:

Even though the single paper has 100 citations, it is possible to only have at most 1 paper with at least 1 citation. Therefore, h-index is 1.

Constraints

  • 1 ≤ n ≤ 5000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!