```
class Solution {
public:
int findContentChildren(vector<int>& g, vector<int>& s) {
int res = 0, m = g.size(), n = s.size();
sort(g.begin(), g.end());
sort(s.begin(), s.end());
for (int i = 0, j = 0; i < m && j < n; ++i, ++j) { // asign from the smallest size candy to see if can content a child
while (j < n && s[j] < g[i]) ++j;
if (j < n) ++res;
}
return res;
}
};
```