You have numBottles full water bottles. Drinking a full bottle leaves one empty bottle. You may exchange exactly numExchange empty bottles for one full bottle, then drink it and reuse its empty bottle in later exchanges. Return the maximum total number of bottles you can drink.
Filled bottles contain water; outlined bottles are empty. Arrows show drinking and exchange steps.
Example 1:
Input: numBottles = 5
numExchange = 3
Output: 7Explanation: Drink the initial five bottles. Exchange three empties for one full bottle, then drink it to have three empties again. One more exchange and drink gives a total of 7 bottles.
Example 2:
Input: numBottles = 2
numExchange = 3
Output: 2Explanation: After drinking both bottles, only two empties remain. That is fewer than the three needed for an exchange, so the total is 2.
Example 3:
Input: numBottles = 3
numExchange = 2
Output: 5Explanation: Drink the initial three bottles. Exchange two empties and drink the new bottle, leaving two empties. Exchange and drink once more for a total of 5 bottles.
Constraints:
1 <= numBottles <= 1002 <= numExchange <= 100