Description
Given a sorted array of citations in ascending order, return the h-index in O(log n) time using binary search.
Examples
Input:
citations = [0,1,3,5,6]Output:
3Explanation:
3 papers with ≥3 citations.
Input:
citations = [0,0,0,4,4]Output:
2Explanation:
2 papers have at least 2 citations each. It is not possible to have h-index of 3 because only 2 papers have ≥3 citations, but the requirement is at least 3 papers with ≥3 citations.
Input:
citations = [10,10,10,10,10]Output:
5Explanation:
All 5 papers have at least 5 citations each, so the h-index is 5. This demonstrates the case where all papers exceed the h-index threshold.
Constraints
- •
1 ≤ n ≤ 10⁵