Skip to content

Commit b707317

Browse files
authored
rust solution added to README
1 parent ac12951 commit b707317

File tree

1 file changed

+19
-0
lines changed
  • solution/3100-3199/3100.Water Bottles II

1 file changed

+19
-0
lines changed

solution/3100-3199/3100.Water Bottles II/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ function maxBottlesDrunk(numBottles: number, numExchange: number): number {
156156
}
157157
```
158158

159+
#### Rust
160+
161+
```rust
162+
impl Solution {
163+
pub fn max_bottles_drunk(mut num_bottles: i32, mut num_exchange: i32) -> i32 {
164+
let mut ans = num_bottles;
165+
166+
while num_bottles >= num_exchange {
167+
num_bottles -= num_exchange;
168+
num_exchange += 1;
169+
ans += 1;
170+
num_bottles += 1;
171+
}
172+
173+
ans
174+
}
175+
}
176+
```
177+
159178
<!-- tabs:end -->
160179

161180
<!-- solution:end -->

0 commit comments

Comments
 (0)