The researcher's score
- O(n log n) · Hard
- Full plan
- Python
- JavaScript
- lists
- sorting
- comparisons
Problem
The observatory's committee is handing out grants, and it doesn't want to reward only those who publish a lot, nor those with a single famous paper. So it grades each researcher with a score that asks for both. Write a function that takes citations, a list of integers from 0 up (how many times each of her papers was cited; it may be empty), and returns an integer: the largest number h such that she has at least h papers with h or more citations each.
With [3, 0, 6, 1, 5] the score is 3: three papers have 3 citations or more (the 3, the 6 and the 5). It doesn't reach 4, because only two have 4 or more. A single paper with 100 citations gives 1, not 100. With no papers, or if none of them was cited, the score is 0.
Examples
The one from the example
[3, 0, 6, 1, 5] → 3
Four equal papers
[4, 4, 4, 4] → 4
One heavily cited paper doesn't raise the score
[25, 8, 5, 3, 3] → 3
Nobody cited them
[0, 0, 0] → 0
No papers
[] → 0
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def score(citations):
passJavaScript
function score(citations) {
}It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.