Skip to content

Commit 1727829

Browse files
authored
Solution
0ms Runtime 2.04 mb Memory space
1 parent b9dc478 commit 1727829

File tree

1 file changed

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

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
impl Solution {
2+
pub fn find_the_winner(n: i32, k: i32) -> i32 {
3+
if n == 1 {
4+
return 1;
5+
}
6+
let mut ans = (k + Solution::find_the_winner(n - 1, k)) % n;
7+
return if ans == 0 { n } else { ans };
8+
}
9+
}

0 commit comments

Comments
 (0)