diff --git a/solution/3100-3199/3100.Water Bottles II/README.md b/solution/3100-3199/3100.Water Bottles II/README.md index cd42288b095a4..a4c8bc740d527 100644 --- a/solution/3100-3199/3100.Water Bottles II/README.md +++ b/solution/3100-3199/3100.Water Bottles II/README.md @@ -162,14 +162,12 @@ function maxBottlesDrunk(numBottles: number, numExchange: number): number { impl Solution { pub fn max_bottles_drunk(mut num_bottles: i32, mut num_exchange: i32) -> i32 { let mut ans = num_bottles; - while num_bottles >= num_exchange { num_bottles -= num_exchange; num_exchange += 1; ans += 1; num_bottles += 1; } - ans } } diff --git a/solution/3100-3199/3100.Water Bottles II/README_EN.md b/solution/3100-3199/3100.Water Bottles II/README_EN.md index e42d998765acf..0a664e60f6707 100644 --- a/solution/3100-3199/3100.Water Bottles II/README_EN.md +++ b/solution/3100-3199/3100.Water Bottles II/README_EN.md @@ -161,14 +161,12 @@ function maxBottlesDrunk(numBottles: number, numExchange: number): number { impl Solution { pub fn max_bottles_drunk(mut num_bottles: i32, mut num_exchange: i32) -> i32 { let mut ans = num_bottles; - while num_bottles >= num_exchange { num_bottles -= num_exchange; num_exchange += 1; ans += 1; num_bottles += 1; - } - + }0 ans } } diff --git a/solution/3100-3199/3100.Water Bottles II/Solution.rs b/solution/3100-3199/3100.Water Bottles II/Solution.rs index eedc8a37aa3c6..d43af2b73f992 100644 --- a/solution/3100-3199/3100.Water Bottles II/Solution.rs +++ b/solution/3100-3199/3100.Water Bottles II/Solution.rs @@ -1,14 +1,12 @@ -impl Solution { - pub fn max_bottles_drunk(mut num_bottles: i32, mut num_exchange: i32) -> i32 { - let mut ans = num_bottles; - - while num_bottles >= num_exchange { - num_bottles -= num_exchange; - num_exchange += 1; - ans += 1; - num_bottles += 1; - } - - ans - } -} +impl Solution { + pub fn max_bottles_drunk(mut num_bottles: i32, mut num_exchange: i32) -> i32 { + let mut ans = num_bottles; + while num_bottles >= num_exchange { + num_bottles -= num_exchange; + num_exchange += 1; + ans += 1; + num_bottles += 1; + } + ans + } +}