#274

H-Index

expert · 1035 · lc medium +32 · verified · 41.2% accepted · 1,879 likes · top 21%

play →

Description

A researcher has published papers, and the array citations records citations[i] as the citation count for paper i. Return the researcher's h-index: the largest integer h such that at least h of the papers each have at least h citations.

Example 1:

Input: citations = [3,0,6,1,5]
Output: 3
Explanation: [3,0,6,1,5] means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively.
Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3.

Example 2:

Input: citations = [1,3,1]
Output: 1

Code

1
2
3