Leetcode 275 Solution
This article provides solution to leetcode question 275 (h-index-ii).
Access this page by simply typing in "lcs 275" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/h-index-ii
Solution
class Solution {
public:
int hIndex(vector<int>& citations) {
int l = 0;
int r = citations.size() - 1;
while (l <= r)
{
int m = (l + r) / 2;
if (citations[m] >= citations.size() - m)
r = m - 1;
else
l = m + 1;
}
return citations.size() - l;
}
};