leetcode

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

commit938b692ac94451317ef6757e57f8653fc0de6772
parent7fa2da482a8f351409139789b98197777e975abb
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateFri, 6 Jan 2023 20:43:47 +0100

Daily problem

Diffstat:
AProblems/1833.cpp|++++++++++
MREADME.md|+

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) |