Skip to content

Commit 9bdd7f6

Browse files
authored
Update README_EN.md
1 parent 82937e0 commit 9bdd7f6

File tree

1 file changed

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

1 file changed

+18
-9
lines changed

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,29 @@ func findTheWinner(n int, k int) int {
140140

141141
```ts
142142
function findTheWinner(n: number, k: number): number {
143-
if (n === 1) return 1;
144-
const res = (findTheWinner(n - 1, k) + k) % n;
145-
return res ? res : n;
143+
if (n === 1) {
144+
return 1;
145+
}
146+
const ans = (k + findTheWinner(n - 1, k)) % n;
147+
return ans ? ans : n;
146148
}
147149
```
148150

149151
#### JavaScript
150152

151153
```js
152-
function findTheWinner(n, k) {
153-
if (n === 1) return 1;
154-
const res = (findTheWinner(n - 1, k) + k) % n;
155-
return res ? res : n;
156-
}
154+
/**
155+
* @param {number} n
156+
* @param {number} k
157+
* @return {number}
158+
*/
159+
var findTheWinner = function (n, k) {
160+
if (n === 1) {
161+
return 1;
162+
}
163+
const ans = (k + findTheWinner(n - 1, k)) % n;
164+
return ans ? ans : n;
165+
};
157166
```
158167

159168
<!-- tabs:end -->
@@ -162,7 +171,7 @@ function findTheWinner(n, k) {
162171

163172
<!-- solution:start -->
164173

165-
### Solution 2. Simulation
174+
### Solution 2: Simulation
166175

167176
<!-- tabs:start -->
168177

0 commit comments

Comments
 (0)