Class Solution
-
- All Implemented Interfaces:
public final class Solution3100 - Water Bottles II\.
Medium
You are given two integers
numBottlesandnumExchange.numBottlesrepresents the number of full water bottles that you initially have. In one operation, you can perform one of the following operations:Drink any number of full water bottles turning them into empty bottles.
Exchange
numExchangeempty bottles with one full water bottle. Then, increasenumExchangeby one.
Note that you cannot exchange multiple batches of empty bottles for the same value of
numExchange. For example, ifnumBottles == 3andnumExchange == 1, you cannot exchange3empty water bottles for3full bottles.Return the maximum number of water bottles you can drink.
Example 1:
Input: numBottles = 13, numExchange = 6
Output: 15
Explanation: The table above shows the number of full water bottles, empty water bottles, the value of numExchange, and the number of bottles drunk.
Example 2:
Input: numBottles = 10, numExchange = 3
Output: 13
Explanation: The table above shows the number of full water bottles, empty water bottles, the value of numExchange, and the number of bottles drunk.
Constraints:
1 <= numBottles <= 1001 <= numExchange <= 100
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegermaxBottlesDrunk(Integer numBottles, Integer numExchange)-
-
Method Detail
-
maxBottlesDrunk
final Integer maxBottlesDrunk(Integer numBottles, Integer numExchange)
-
-
-
-