H-Index - Problem
Imagine you're a researcher who has published several papers, and you want to measure your academic impact using the prestigious H-Index metric.
Given an array citations where citations[i] represents the number of citations your i-th paper has received, calculate your H-Index.
The H-Index is defined as: The maximum value h such that you have published at least h papers that have each been cited at least h times.
Example: If you have papers with citations [3, 0, 6, 1, 5], your H-Index is 3 because you have 3 papers with at least 3 citations each (papers with 3, 6, and 5 citations), but you don't have 4 papers with at least 4 citations each.
Input & Output
example_1.py โ Standard Case
$
Input:
[3,0,6,1,5]
โบ
Output:
3
๐ก Note:
The researcher has 3 papers with at least 3 citations each (papers with 3, 6, and 5 citations), but only 2 papers with at least 4 citations each. So the H-Index is 3.
example_2.py โ All High Citations
$
Input:
[1,3,1]
โบ
Output:
1
๐ก Note:
The researcher has only 1 paper with at least 3 citations, 2 papers with at least 1 citation. The maximum H-Index possible is 1.
example_3.py โ Edge Case Single Paper
$
Input:
[100]
โบ
Output:
1
๐ก Note:
With only 1 paper (even with 100 citations), the maximum H-Index is 1, since we can have at most 1 paper with at least 1 citation.
Constraints
- n == citations.length
- 1 โค n โค 5000
- 0 โค citations[i] โค 1000
Visualization
Tap to expand
Understanding the Visualization
1
Understand the Problem
We need the maximum h where we have โฅh papers with โฅh citations each
2
Sort by Citations
Arrange papers in descending order of citations for easier analysis
3
Find the Balance Point
The H-Index is where the number of papers meets the citation requirement
4
Optimal Counting
Use buckets to count efficiently without sorting
Key Takeaway
๐ฏ Key Insight: The H-Index represents the perfect balance between quantity and quality of research impact - the highest number where you have that many highly-cited papers.
๐ก
Explanation
AI Ready
๐ก Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code