Posted on

Description

Submission

class Solution {
public:
    int findContentChildren(vector<int>& g, vector<int>& s) {
        sort(g.begin(), g.end());
        sort(s.begin(), s.end());

        int ret = 0;
        for(int i = 0, j = 0; i < g.size() && j < s.size(); ) {
            if(g[i] <= s[j]) {
                ++i;
                ++j;
                ++ret;
            } else {
                ++j;
            }
        }
        return ret;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *