LeetCode275. H 指数 II

class Solution {
public:
    int hIndex(vector<int>& citations) {
        int n = citations.size();
        int res = 0;
        for(int i = n - 1; i >= 0; --i) {
            if(citations[i] >= n - i) {
                res = max(res, n - i);
            } else {
                break;
            }
        }
        return res;
    }
};
posted @ 2020-08-28 09:37  machine_gun_lin  阅读(92)  评论(0)    收藏  举报