// Custom comparator function for sorting in reverse order
bool reverseComparator(int a, int b) {
return a > b; // '>' will sort in descending order (reverse), '<' will sort in ascending order
}
class Solution {
public:
int findContentChildren(vector<int>& g, vector<int>& s) {
sort(s.begin(),s.end(),reverseComparator);
sort(g.begin(),g.end(),reverseComparator);
int cnt = 0;
int p = 0;
for (int cookiesize : s) {
while (p < g.size() && g[p] > cookiesize) p ++ ;
if (p >= g.size()) break;
// if (cookiesize >= g[p]) {
cnt ++ ;
p ++;
// }
}
return cnt;
}
};