H-Index II
Thoughts
Code
class Solution {
public int hIndex(int[] citations) {
int n = citations.length;
int start = 0, end = n;
while (start < end) {
int mid = start + (end - start) / 2;
if (n - mid > citations[mid]) {
start = mid + 1;
} else {
end = mid;
}
}
return n - start;
}
}Analysis
Last updated