Skip to content

Commit 7ed5b7c

Browse files
3100. Water Bottles II.cpp is added
1 parent 02717fd commit 7ed5b7c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

3100. Water Bottles II.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int maxBottlesDrunk(int numBottles, int numExchange) {
4+
int bottleDrunk = numBottles;
5+
int emptyBottles = numBottles;
6+
7+
while (emptyBottles >= numExchange) {
8+
emptyBottles -= numExchange;
9+
numExchange++;
10+
bottleDrunk++;
11+
emptyBottles++;
12+
}
13+
return bottleDrunk;
14+
}
15+
};

0 commit comments

Comments
 (0)