Maximum Drinks from Full Bottles and Empty-Bottle Exchanges
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
### Problem
Begin with numBottles full bottles. Drinking one yields one empty bottle. Exchange numExchange empty bottles for one full bottle as often as possible. Return the maximum number of bottles you can drink; borrowing bottles is not part of the rules.
```cpp
class Solution {
public:
int numWaterBottles(int numBottles, int numExchange);
};
```
### Examples
**Example 1:**
```text
Input: numBottles = 5, numExchange = 2
Output: 9
Explanation: Drink5,then exchange empties to drink2,then1,then1 more:5+2+1+1=9.
```
**Example 2:**
```text
Input: numBottles = 2, numExchange = 3
Output: 2
Explanation: After the initial drinks,there are too few empties for an exchange.
```
### Constraints
- `1 <= numBottles <= 100`.
- `2 <= numExchange <= 100`.
### Contract considerations
Only empty bottles may be exchanged.
```hint Read the boundary condition
Respect the fixed exchange cost and retain unused empty bottles. Include an initial supply too small for any exchange; borrowing is unavailable.
```
### Boundary reminders
Only empty bottles may be exchanged.
Overview: Maximum Drinks from Full Bottles and Empty-Bottle Exchanges. Begin with numBottles full bottles. Drinking one yields one empty bottle.
Maximum Drinks from Full Bottles and Empty-Bottle Exchanges
Google
Aug 17, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0
Problem
Begin with numBottles full bottles. Drinking one yields one empty bottle. Exchange numExchange empty bottles for one full bottle as often as possible. Return the maximum number of bottles you can drink; borrowing bottles is not part of the rules.
class Solution {
public:
int numWaterBottles(int numBottles, int numExchange);
};