LeetCode 455. 分发饼干

题目描述:

解法:

class Solution {
public:
    int findContentChildren(vector<int>& g, vector<int>& s) {
        sort(g.begin(),g.end());
        sort(s.begin(),s.end());
        int i=0,j=0;
        while(i<g.size()&&j<s.size()){
            if(g[i]<=s[j++]){
                i++;
            }
        }
        return i;
    }
};

 

posted @ 2019-09-01 20:11  DH_HUSTer  阅读(16)  评论(0编辑  收藏  举报