Ctrl K

Impact Score From a Sorted List

Medium
cites[i] is how many times a researcher's paper i has been cited; the list is sorted in non-decreasing order. The author's impact score is the largest number h such that the author has at least h papers, each cited at least h times. Return the impact score. Your solution must run in logarithmic time.
Example 1
cites=[1, 2, 2, 5, 8, 10] → 3

The last three papers have at least 3 citations each (5, 8, 10), but there are not four papers with 4 or more. The answer is 3.

Example 2
cites=[0, 3, 3, 3] → 3

Three papers with 3 citations give an answer of 3; there are not four papers with 4 or more.

Example 3
cites=[0] → 0
Constraints
  • 1 ≤ len(cites) ≤ 10⁵
  • 0 ≤ cites[i] ≤ 1000
  • cites is sorted in non-decreasing order
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsFind in a Shifted Sorted Array MediumFirst and Last Copy MediumFind in a Row-Chained Grid MediumFind in a Shifted Array With Repeats MediumMinimum of a Shifted List Medium
loading Python…
Input
cites=[1, 2, 2, 5, 8, 10]
Expected
3

Run checks the first 3 tests in your browser. Submit checks all 81 tests on the server, hidden ones included.