Skip to content

Commit 3142012

Browse files
authored
Update README.md
1 parent 1727829 commit 3142012

File tree

1 file changed

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

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,20 @@ function findTheWinner(n: number, k: number): number {
149149
}
150150
```
151151

152+
#### Rust
153+
154+
```rust
155+
impl Solution {
156+
pub fn find_the_winner(n: i32, k: i32) -> i32 {
157+
if n == 1 {
158+
return 1;
159+
}
160+
let mut ans = (k + Solution::find_the_winner(n - 1, k)) % n;
161+
return if ans == 0 { n } else { ans };
162+
}
163+
}
164+
```
165+
152166
#### JavaScript
153167

154168
```js

0 commit comments

Comments
 (0)