Assign Cookies

2017/12/9 posted in  leetcode

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