3100: Water-Bottles-II
Medium
table of contents
It is just a simulation question; just follow the steps provided in the question directly and you will reach the answer! (the constraints provided are tiny)
code
class Solution {
public:
int maxBottlesDrunk(int numBottles, int numExchange) {
int ans = numBottles;
while (++numBottles > numExchange) {
++ans;
numBottles -= numExchange++;
}
return ans;
}
};(could technically solve this using math too but like this is waaaaay easier)