此题虽然能过,但是并未使用o(logn)的解法, mark一下,下次来解。
class Solution { public: int hIndex(vector<int>& citations) { //sort(citations.begin(), citations.end(), greater<int>()); int size = citations.size(); int max = 0; for (int i = size - 1; i >= 0; i--) { int j = size - 1 - i; if (citations[i] >= j + 1) { max = j + 1; } } return max; } };