H-Index II
MediumBinary Search
Decode it first. Clues, constraints, pattern and plan before any code.A researcher's papers have citation counts citations, sorted in ascending order. Their h-index is the largest h such that at least h papers have at least h citations each. Return it, in logarithmic time.
citations = [0, 1, 3, 5, 6] → 3 (three papers have at least 3 citations)
citations = [1, 2, 100] → 2
citations = [0] → 0Constraints
1 <= citations.length <= 10^50 <= citations[i] <= 1000citationsis sorted in ascending order.