Skip to content

Commit 3b83c30

Browse files
authored
Rust Solution Added to README_EN
1 parent b9dc478 commit 3b83c30

File tree

1 file changed

+17
-0
lines changed
  • solution/1800-1899/1823.Find the Winner of the Circular Game

1 file changed

+17
-0
lines changed

solution/1800-1899/1823.Find the Winner of the Circular Game/README_EN.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ var findTheWinner = function (n, k) {
165165
};
166166
```
167167

168+
#### Rust
169+
170+
```rust
171+
impl Solution {
172+
pub fn find_the_winner(n: i32, k: i32) -> i32 {
173+
if n == 1 {
174+
return 1;
175+
}
176+
let mut ans = (k + Solution::find_the_winner(n - 1, k)) % n;
177+
return if ans == 0 { n } else { ans };
178+
}
179+
}
180+
```
181+
182+
183+
184+
168185
<!-- tabs:end -->
169186

170187
<!-- solution:end -->

0 commit comments

Comments
 (0)