Problem · Array
H-Index II
Learn this problemProblem statement
citations is sorted in nondecreasing order. Return the greatest integer h such that at least h papers each have at least h citations.
Your solution must run in O(log n) time.
Function
hIndexSorted(citations: int[]) → intExamples
Example 1
citations = [0,1,3,5,6]return = 3Three papers have at least three citations.
Example 2
citations = [1,2,100]return = 2Two papers have at least two citations.
Constraints
0 <= citations.length <= 1000000 <= citations[i] <= 10^9citationsis sorted in nondecreasing order.