leetcode 274 H-Index

参考:https://www.cnblogs.com/grandyang/p/4781203.html

class Solution {
public:
    int hIndex(vector<int>& citations) {
        sort(citations.begin(),citations.end(),greater<int>());
        for(int i=0;i<citations.size();++i) {
            if(i>=citations[i]) return i;
        }
        return citations.size();
    }
};

 

posted @ 2020-03-26 11:36  qiujiejie  阅读(97)  评论(0编辑  收藏  举报