200. H-Index
Medium · Sorting
Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their i-th paper, return the researcher's **h-index**.
The h-index is defined as the maximum value `h` such that the researcher has published at least `h` papers that have each been cited at least `h` times.
For example, if a researcher has 5 papers with citation counts [3, 0, 6, 1, 5], the h-index is 3 because they have 3 papers with at least 3 citations each (3, 6, and 5), but do not have 4 papers with at least 4 citations each.
Examples
Example 1 Input: citations = [3, 0, 6, 1, 5] Output: 3 Explanation: The researcher has 3 papers with at least 3 citations (papers with 3, 6, and 5 citations). There is no way to get h=4 since only 2 papers have 4+ citations.
Example 2 Input: citations = [1, 3, 1] Output: 1 Explanation: The researcher has 1 paper with at least 3 citations, 2 papers with at least 1 citation. The maximum h where at least h papers have h+ citations is h=1.
Constraints
- Standard input/output constraints apply