LeetCode/cpp/assign-cookies.cpp
Matej Focko b229608723
cpp(chore): add clang-format style and format
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-01-03 12:06:54 +01:00

20 lines
447 B
C++

#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;
}
};