Min Max Game LeetCode solution in JavaScript

1
var minMaxGame = function (nums) {
2
while (nums.length > 1) {
3
let half = nums.length / 2;
4
for (let i = 0; i < half; i++)
5
nums[i] =
6
i % 2 === 0
7
? Math.min(nums[2 * i], nums[2 * i + 1])
8
: Math.max(nums[2 * i], nums[2 * i + 1]);
9

10
nums.length = half;
11
}
12

13
return nums[0];
14
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0