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

if `child[res]`

can be content with `cookie[i]`

,

then `++res`

,++i,

else just ++i;

finally , res is the number we want