leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | 0778f15ed04bd09dc551a19993bde58d81d37a34 |
parent | 4381d881f23617d103dcc7b1ba6c164010b37484 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Fri, 12 Apr 2024 10:58:35 +0200 |
1 Random Problem
Diffstat:A | Problems/3100.cpp | | | +++++++++++++ |
M | README.md | | | + |
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/Problems/3100.cpp b/Problems/3100.cpp
@@ -0,0 +1,13 @@
class Solution {
public:
int maxBottlesDrunk(int numBottles, int numExchange) const {
int res = 0;
while (numBottles >= numExchange) {
numBottles -= numExchange;
res += numExchange;
numBottles++;
numExchange++;
}
return res + numBottles;
}
};
diff --git a/README.md b/README.md
@@ -1193,4 +1193,5 @@ for solving problems.
| 3034 | Medium | [Number of Subarrays That Match a Pattern I](Problems/3034.cpp) |
| 3039 | Medium | [Apply Operations to Make String Empty](Problems/3039.cpp) |
| 3070 | Medium | [Count Submatrices with Top-Left Element and Sum Less Than k](Problems/3070.cpp) |
| 3100 | Medium | [Water Bottles II](Problems/3100.cpp) |
| 3101 | Medium | [Count Alternating Subarrays](Problems/3101.cpp) |