Problem 331938 · medium · Level 03 Linear Management & Searching

Citations on the Faculty Web Page

binary search · arrays

A faculty web page lists how often each of a researcher's papers has been cited, already sorted from fewest to most: citations[i] is the count for paper i. Her h-index is the biggest h for which she has h or more papers that were each cited at least h times. Return it, using the sorted order so that you do not have to look at every paper.

Examples

Input:  citations = [1, 2, 4, 7, 9, 12]
Output: 4
Explanation: four papers (4, 7, 9, 12) have at least 4 citations; five papers do not have at least 5.

Input:  citations = [3, 50, 60]
Output: 3

Input:  citations = [0, 0]
Output: 0

Constraints

  • 0 <= len(citations) <= 10**6, 0 <= citations[i] <= 10**9
  • Required time: O(log n).

Goals

  • Express the h-index condition in terms of an index into the sorted list
  • Return the count derived from the boundary, not the boundary itself
Starting Python…