H-Index II
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public class Solution { public int hIndex(int[] citations) { int l = 0; int r = citations.length - 1; while(l<=r) { int m = l + (r-l) / 2; if(citations[m] < citations.length - m) l=m+1; else r=m-1; } return citations.length - l; } } |
Leave A Comment