1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-10 00:09:06 +01:00

cpp: add “455. Assign Cookies”

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-01-01 23:29:56 +01:00
parent 48847d9631
commit 9af5c9e61e
Signed by: mfocko
GPG key ID: 7C47D46246790496

21
cpp/assign-cookies.cpp Normal file
View file

@ -0,0 +1,21 @@
#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;
}
};