1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00
LeetCode/cpp/assign-cookies.cpp

21 lines
447 B
C++
Raw Normal View History

#include <algorithm>
#include <vector>
class Solution {
public:
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;
}
};