Water Bottles
You start with full full bottles. You drink a bottle, which makes it empty. At any time you may trade exchange empty bottles for one new full bottle. Return the greatest number of bottles you can drink in total.
Example 1
full 9
exchange 3
returns 13
Drink 9, trade 9 empties for 3, drink 3, trade 3 for 1, drink 1: 13.
Constraints
1 <= full <= 1002 <= exchange <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Balanced Parentheses CountMedium
- Convert to Base Minus TwoMedium
- Count Numbers With Unique DigitsMedium
- Count PrimesMedium
- Day of the WeekMedium
- Fast PowerMedium
- Friday the 13th CountMedium
- Last Digit of a PowerMedium