Skip to content

Commit cd8393f

Browse files
authored
Merge pull request #49 from masx200/deno-dependency-updates
Update dependencies
2 parents 3563e39 + 04e3545 commit cd8393f

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

min-max-game/index.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
function minMaxGame(nums: number[]): number {
2-
3-
4-
52
while (nums.length !== 1) {
3+
const n = nums.length;
64

7-
8-
9-
const n = nums.length;
10-
11-
const newNums: number[]= new Array(Math.floor(n / 2)).fill(0).map((_,i)=>i % 2 === 0?Math.min(nums[2 * i], nums[2 * i + 1]):Math.max(nums[2 * i], nums[2 * i + 1]));
12-
13-
5+
const newNums: number[] = new Array(Math.floor(n / 2)).fill(0).map((
6+
_,
7+
i,
8+
) => i % 2 === 0
9+
? Math.min(nums[2 * i], nums[2 * i + 1])
10+
: Math.max(nums[2 * i], nums[2 * i + 1])
11+
);
1412

1513
nums = newNums;
16-
17-
18-
1914
}
2015

2116
return nums[0];
22-
2317
}
24-
export default minMaxGame
18+
export default minMaxGame;

0 commit comments

Comments
 (0)