502. H-Index II (Binary Search)

MediumBinary SearchBinary SearchArray

Given an array of citation counts sorted in ascending order, return the researcher's h-index: the maximum value h such that the researcher has at least h papers each cited at least h times. Use binary search. Input: an ascending array of citations.

Input: An ascending array of citations.

Output: Integer — the h-index.

Examples

Example 1
Input: [0,1,3,5,6]
Output: 3
Explanation: 3 papers have >= 3 citations.
Example 2
Input: [1,2,100]
Output: 2
Explanation: h-index is 2.
Example 3
Input: [0]
Output: 0
Explanation: No cited papers.

Constraints

Asked by

MetaGoogle
Solve this problem in the editor →