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