275. H-Index II
class Solution { public: int hIndex(vector<int>& citations) { if (citations.size() == 0) return 0; int i = 0, j = citations.size(); while (i < j - 1) { int m = i + (j - i) / 2; int pos = citations.size() - m; if (m == citations[pos]) return m; else if (m > citations[pos]) j = m; else i = m; } if (j == citations.size() && citations[0] >= citations.size() || citations[citations.size() - j] >= j) return j; return i; } };