274. H-Index
common sense 直接sort 然后找citations > len-i
可以直接用一个bucket记录 然后大于N的全部记录在N上 因为hindex不可能大于N
https://leetcode.com/problems/h-index/discuss/70768/Java-bucket-sort-O(n)-solution-with-detail-explanation
1 class Solution { 2 public int hIndex(int[] citations) { 3 if(citations.length == 0) return 0; 4 Arrays.sort(citations); 5 int lo = 0, hi = citations.length - 1; 6 int len = citations.length; 7 for(int i = 0; i < len; i++){ 8 if(citations[i] >= len - i){ 9 return len - i; 10 } 11 } 12 return 0; 13 14 } 15 }