LeetCode 274. H指数

bool cmp (int i,int j) { return (i>j);}
class Solution {
public:
    int hIndex(vector<int>& citations) {


        int count = 0;
        sort(citations.begin(),citations.end(),cmp);
        for(int i = 0; i < citations.size(); i++){
            if(citations[i]>count)
                count++;
            else
                break;
        }
        return count;
    }
};

 

posted @ 2018-08-18 16:10  Lokianyu  阅读(205)  评论(0编辑  收藏  举报