3100. Water Bottles II Medium

@problem@discussion
#Math#Simulation



1/**
2 * [3100] Water Bottles II
3 *
4 * You are given two integers numBottles and numExchange.
5 * numBottles represents the number of full water bottles that you initially have. In one operation, you can perform one of the following operations:
6 * 
7 * 	Drink any number of full water bottles turning them into empty bottles.
8 * 	Exchange numExchange empty bottles with one full water bottle. Then, increase numExchange by one.
9 * 
10 * Note that you cannot exchange multiple batches of empty bottles for the same value of numExchange. For example, if numBottles == 3 and numExchange == 1, you cannot exchange 3 empty water bottles for 3 full bottles.
11 * Return the maximum number of water bottles you can drink.
12 *  
13 * <strong class="example">Example 1:
14 * <img alt="" src="https://assets.leetcode.com/uploads/2024/01/28/exampleone1.png" style="width: 948px; height: 482px; padding: 10px; background: #fff; border-radius: .5rem;" />
15 * Input: numBottles = 13, numExchange = 6
16 * Output: 15
17 * Explanation: The table above shows the number of full water bottles, empty water bottles, the value of numExchange, and the number of bottles drunk.
18 * 
19 * <strong class="example">Example 2:
20 * <img alt="" src="https://assets.leetcode.com/uploads/2024/01/28/example231.png" style="width: 990px; height: 642px; padding: 10px; background: #fff; border-radius: .5rem;" />
21 * Input: numBottles = 10, numExchange = 3
22 * Output: 13
23 * Explanation: The table above shows the number of full water bottles, empty water bottles, the value of numExchange, and the number of bottles drunk.
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= numBottles <= 100 
29 * 	1 <= numExchange <= 100
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/water-bottles-ii/
35// discuss: https://leetcode.com/problems/water-bottles-ii/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn max_bottles_drunk(num_bottles: i32, num_exchange: i32) -> i32 {
41        0
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_3100() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.