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;
}
};
Assign Cookies
Copyright © 2017 Powered by LZH, Theme used GitHub CSS.