232. H-Index
Medium
Counting Buckets
Array
Problem
Given an array citations where citations[i] is the number of citations received by a researcher's ith paper, return the researcher's h-index. The h-index is the maximum h such that at least h papers each have at least h citations.
Examples
Example 1
Input: [3,0,6,1,5]
Output: 3
Example 2
Input: [1,3,1]
Output: 1
Example 3
Input: [0]
Output: 0
Constraints
� 1 <= citations.length <= 5000
� 0 <= citations[i] <= 1000
Hints
?? The h-index can never exceed the number of papers.
?? Citation counts larger than n can all be placed in the same bucket.
?? Accumulate paper counts from high citation counts downward.
Expected Complexity
Time: O(n)
Space: O(n)
Follow-up
Can you solve it in O(n) time without sorting?
Practice Notes
Attempts: 0
Time spent: 0min
Hints used: 0
JavaScript
00:00
Loading...
Case 1
Case 2
Case 3
Input
[3,0,6,1,5]Expected
3