Leetcode 455 Solution
This article provides solution to leetcode question 455 (assign-cookies)
Access this page by simply typing in "lcs 455" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/assign-cookies
Solution
class Solution {
public:
int findContentChildren(vector<int>& g, vector<int>& s) {
sort(g.begin(), g.end());
sort(s.begin(), s.end());
int j = 0, i = 0;
int total = 0;
while (i < s.size() && j < g.size())
{
if (s[i] >= g[j])
total++, i++, j++;
else
i++;
}
return total;
}
};