simple c++ solution


  • 0
    N
    class Solution {
    public:
        int findContentChildren(vector<int>& g, vector<int>& s) {
            int ret = 0;
            vector<int> dup_g(g), dup_s(s);
            sort(dup_g.begin(), dup_g.end());
            sort(dup_s.begin(), dup_s.end());
            for (int i = 0; i < dup_s.size(); ++ i)
                if (ret < dup_g.size() && dup_g[ret] <= dup_s[i]) ret ++;
            return ret;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.