We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ba543a0 commit d48ca2cCopy full SHA for d48ca2c
solution/1800-1899/1823.Find the Winner of the Circular Game/Solution.ts
@@ -1,5 +1,7 @@
1
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;
+ if (n === 1) {
+ return 1;
+ }
5
+ const ans = (k + findTheWinner(n - 1, k)) % n;
6
+ return ans ? ans : n;
7
}
0 commit comments