2024-01-01 23:29:56 +01:00
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class Solution {
|
2024-01-03 12:06:42 +01:00
|
|
|
public:
|
2024-01-01 23:29:56 +01:00
|
|
|
int findContentChildren(std::vector<int> g, std::vector<int> s) {
|
|
|
|
std::sort(g.begin(), g.end());
|
|
|
|
std::sort(s.begin(), s.end());
|
|
|
|
|
|
|
|
int content = 0;
|
|
|
|
for (int i = 0, j = 0; i < g.size() && j < s.size(); ++j) {
|
|
|
|
if (g[i] <= s[j]) {
|
|
|
|
++i;
|
|
|
|
++content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
};
|