1518. Water Bottles Easy
1/**
2 * [1518] Water Bottles
3 *
4 * There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.
5 * The operation of drinking a full water bottle turns it into an empty bottle.
6 * Given the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.
7 *
8 * Example 1:
9 * <img alt="" src="https://assets.leetcode.com/uploads/2020/07/01/sample_1_1875.png" style="width: 500px; height: 245px;" />
10 * Input: numBottles = 9, numExchange = 3
11 * Output: 13
12 * Explanation: You can exchange 3 empty bottles to get 1 full water bottle.
13 * Number of water bottles you can drink: 9 + 3 + 1 = 13.
14 *
15 * Example 2:
16 * <img alt="" src="https://assets.leetcode.com/uploads/2020/07/01/sample_2_1875.png" style="width: 500px; height: 183px;" />
17 * Input: numBottles = 15, numExchange = 4
18 * Output: 19
19 * Explanation: You can exchange 4 empty bottles to get 1 full water bottle.
20 * Number of water bottles you can drink: 15 + 3 + 1 = 19.
21 *
22 *
23 * Constraints:
24 *
25 * 1 <= numBottles <= 100
26 * 2 <= numExchange <= 100
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/water-bottles/
32// discuss: https://leetcode.com/problems/water-bottles/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn num_water_bottles(num_bottles: i32, num_exchange: i32) -> i32 {
38 0
39 }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_1518() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.