leetcode

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

commit 938b692ac94451317ef6757e57f8653fc0de6772
parent 7fa2da482a8f351409139789b98197777e975abb
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Fri,  6 Jan 2023 21:43:47 +0100

Daily problem

Diffstat:
AProblems/1833.cpp | 10++++++++++
MREADME.md | 1+
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Problems/1833.cpp b/Problems/1833.cpp @@ -0,0 +1,10 @@ +class Solution { +public: + int maxIceCream(vector<int> &costs, int coins) { + sort(costs.begin(), costs.end()); + int index = 0, count = 0; + while (index < costs.size() && coins - costs[index] >= 0) + coins -= costs[index++], count++; + return count; + } +}; diff --git a/README.md b/README.md @@ -264,6 +264,7 @@ for solving problems. | 1786 | Medium | [Number of Restricted Paths From First to Last Node](Problems/1786.cpp) | | 1791 | Easy | [Find Center of Star Graph](Problems/1791.cpp) | | 1823 | Medium | [Find the Winner of the Circular Game](Problems/1823.cpp) | +| 1833 | Medium | [Maximum Ice Cream Bars](Problems/1833.cpp) | | 1834 | Medium | [Single-Threaded CPU](Problems/1834.cpp) | | 1926 | Medium | [Nearest Exit from Entrance in Maze](Problems/1926.cpp) | | 1962 | Medium | [Remove Stones to Minimize the Total](Problems/1962.cpp) |