Skip to content

Commit 0564edc

Browse files
authored
Solution.rs
Solution with rust
1 parent cdd0cde commit 0564edc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
impl Solution {
2+
pub fn max_bottles_drunk(mut num_bottles: i32, mut num_exchange: i32) -> i32 {
3+
let mut ans = num_bottles;
4+
5+
while num_bottles >= num_exchange {
6+
num_bottles -= num_exchange;
7+
num_exchange += 1;
8+
ans += 1;
9+
num_bottles += 1;
10+
}
11+
12+
ans
13+
}
14+
}

0 commit comments

Comments
 (0)