leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit ba596d8b3febd098a838c274823f910043b25ae1
parent eeef87223e2abca54973a3b0e714dd24c043253e
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon,  1 Jan 2024 21:31:50 +0000

Daily Problem

Diffstat:
AProblems/0455.cpp | 13+++++++++++++
MREADME.md | 1+
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Problems/0455.cpp b/Problems/0455.cpp @@ -0,0 +1,13 @@ +class Solution { + public: + int findContentChildren(vector<int> &g, vector<int> &s) const { + sort(rbegin(g), rend(g)); + sort(rbegin(s), rend(s)); + int i = 0, j = 0; + while (i < g.size() && j < s.size()) { + if (g[i] <= s[j]) j++; + i++; + } + return j; + } +}; diff --git a/README.md b/README.md @@ -328,6 +328,7 @@ for solving problems. | 0450 | Medium | [Delete Node in a BST](Problems/0450.cpp) | | 0451 | Medium | [Sort Characters By Frequency](Problems/0451.cpp) | | 0452 | Medium | [Minimum Number of Arrows to Burst Balloons](Problems/0452.cpp) | +| 0455 | Easy | [Assign Cookies](Problems/0455.cpp) | | 0456 | Medium | [132 Pattern](Problems/0456.cpp) | | 0458 | Hard | [Poor Pigs](Problems/0458.cpp) | | 0459 | Easy | [Repeated Substring Pattern](Problems/0459.cpp) |