-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathH-index
More file actions
14 lines (12 loc) · 678 Bytes
/
H-index
File metadata and controls
14 lines (12 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher's h-index.
According to the definition of h-index on Wikipedia: The h-index is defined as the maximum value of h such that the given researcher has published at least h papers that have each been cited at least h times.*/
class Solution {
public int hIndex(int[] citations) {
Arrays.sort(citations);
int n = citations.length, res = 0;
for(int i = 0; i < n - res; i++)
if(citations[i] != res)
res = Math.max(res, Math.min(citations[i], n-i));
return res;
}
}