Imagine you're in a desert with a limited supply of water bottles, but there's a clever recycling program! You start with numBottles full water bottles. After drinking each bottle, it becomes empty, but here's the twist: you can exchange empty bottles for new full ones!
The exchange rate is simple: every numExchange empty bottles can be traded for 1 new full bottle. This means you can potentially drink more water than you initially had by being smart about the exchanges.
Goal: Find the maximum total number of water bottles you can drink.
Example: If you have 9 bottles and can exchange every 3 empty bottles for 1 full bottle, you can drink all 9 initially, then exchange the 9 empties for 3 new bottles, drink those 3, and exchange them for 1 more bottle. Total: 9 + 3 + 1 = 13 bottles!
Input & Output
Visualization
Time & Space Complexity
Single calculation using arithmetic operations
Only using constant amount of variables
Constraints
- 1 โค numBottles โค 100
- 2 โค numExchange โค 100
- numExchange > 1 (must be at least 2 for exchanges to make sense)