Skip to content

Commit d48ca2c

Browse files
authored
Update Solution.ts
1 parent ba543a0 commit d48ca2c

File tree

1 file changed

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

1 file changed

+5
-3
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
function findTheWinner(n: number, k: number): number {
2-
if (n === 1) return 1;
3-
const res = (findTheWinner(n - 1, k) + k) % n;
4-
return res ? res : n;
2+
if (n === 1) {
3+
return 1;
4+
}
5+
const ans = (k + findTheWinner(n - 1, k)) % n;
6+
return ans ? ans : n;
57
}

0 commit comments

Comments
 (0)