The H-Index Challenge
The H-index is a metric used to measure the impact of a researcher's publications. It's defined as the largest number 'h' such that a scholar has at least 'h' papers that have been cited at least 'h' times. This challenge asks you to implement a function that calculates the H-index for a given list of publication citation counts. Understanding this metric is crucial for academic institutions to evaluate research productivity and impact.
Problem Description
You are given a list of non-negative integers, where each integer represents the number of citations a research paper has received. Your task is to calculate and return the H-index of this researcher.
The H-index is defined as the largest integer 'h' such that the researcher has at least 'h' papers with at least 'h' citations.
Key Requirements:
- Given a list of citation counts for a researcher's papers.
- Calculate the H-index based on the definition.
Expected Behavior:
- The function should return a single non-negative integer representing the H-index.
Edge Cases to Consider:
- An empty list of publications.
- A list where all papers have zero citations.
- A list where all papers have a very high number of citations.
Examples
Example 1:
Input: [3, 0, 6, 1, 5]
Output: 3
Explanation:
The papers have citation counts: 3, 0, 6, 1, 5.
Let's sort them in descending order: [6, 5, 3, 1, 0].
- For h = 1: There is 1 paper with at least 1 citation (6). So, h=1 is possible.
- For h = 2: There are 2 papers with at least 2 citations (6, 5). So, h=2 is possible.
- For h = 3: There are 3 papers with at least 3 citations (6, 5, 3). So, h=3 is possible.
- For h = 4: There are only 3 papers with at least 4 citations (6, 5). So, h=4 is NOT possible.
The largest such 'h' is 3.
Example 2:
Input: [1, 3, 1]
Output: 1
Explanation:
Sorted citations: [3, 1, 1].
- For h = 1: There is 1 paper with at least 1 citation (3). So, h=1 is possible.
- For h = 2: There are only 1 paper with at least 2 citations (3). So, h=2 is NOT possible.
The largest such 'h' is 1.
Example 3:
Input: [0]
Output: 0
Explanation:
Sorted citations: [0].
- For h = 1: There are 0 papers with at least 1 citation. So, h=1 is NOT possible.
The largest such 'h' is 0.
Constraints
- The input list will contain between 0 and 1000 elements, inclusive.
- Each element in the input list will be a non-negative integer representing citation counts.
- The number of citations for any single paper will not exceed 1000.
- Your solution should aim for an efficient time complexity, ideally better than O(N^2), where N is the number of publications.
Notes
- Consider how sorting the citation counts might simplify the problem.
- Think about the relationship between the sorted citation counts and the potential H-index values.
- The H-index can never be greater than the number of papers.