leetcode

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

commit b88b4777bef8a3a35c05812eaa3f4b05a68d8f9e
parent 59e66b07398f639b276d5fad8f751523ab0d8e1b
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sun,  7 Jul 2024 21:15:56 +0200

1 Random Problem

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

diff --git a/Problems/1518.cpp b/Problems/1518.cpp @@ -0,0 +1,13 @@ +class Solution { + public: + int numWaterBottles(int numBottles, int numExchange) const { + int res = numBottles; + + while (numBottles >= numExchange) { + numBottles -= numExchange - 1; + res++; + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -858,6 +858,7 @@ for solving problems. | 1512 | Easy | [Number of Good Pairs](Problems/1512.cpp) | | 1514 | Medium | [Path with Maximum Probability](Problems/1514.cpp) | | 1517 | Easy | [Find Users With Valid E-Mails](Problems/1517.cpp) | +| 1518 | Easy | [Water Bottles](Problems/1518.cpp) | | 1519 | Medium | [Number of Nodes in the Sub-Tree With the Same Label](Problems/1519.cpp) | | 1523 | Easy | [Count Odd Numbers in an Interval Range](Problems/1523.cpp) | | 1525 | Medium | [Number of Good Ways to Split a String](Problems/1525.cpp) |