Tap here to switch tabs
Problem
Submissions

Problem: Min Max Game

med
30 min
Try to solve the Min Max Game problem.

Statement

You are given a 00 indexed integer array nums whose length is a power of 22.

Apply the following algorithm on nums:

  1. If the length of nums is equal to 11, stop the process and return nums[00].

  2. Create a new 00 indexed integer array newNums of length nums.length /2/ 2.

  3. For every even index i where 0≤0 \leq i << nums.length /2/ 2, assign newNums[i] =min⁡(= \min(nums[2imes2 imes i], nums[2imes2 imes i +1+ 1]).

  4. For every odd index i where 0≤0 \leq i << nums.length /2/ 2, assign newNums[i] =max⁡(= \max(nums[2imes2 imes i], nums[2imes2 imes i +1+ 1]).

  5. Replace the array nums with newNums.

  6. Repeat the entire process from step 11.

Return the final remaining value in nums after applying the algorithm.

Constraints:

  • 1≤1 \leq nums.length ≤1024\leq 1024

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • nums.length is a power of 22.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Min Max Game

med
30 min
Try to solve the Min Max Game problem.

Statement

You are given a 00 indexed integer array nums whose length is a power of 22.

Apply the following algorithm on nums:

  1. If the length of nums is equal to 11, stop the process and return nums[00].

  2. Create a new 00 indexed integer array newNums of length nums.length /2/ 2.

  3. For every even index i where 0≤0 \leq i << nums.length /2/ 2, assign newNums[i] =min⁡(= \min(nums[2imes2 imes i], nums[2imes2 imes i +1+ 1]).

  4. For every odd index i where 0≤0 \leq i << nums.length /2/ 2, assign newNums[i] =max⁡(= \max(nums[2imes2 imes i], nums[2imes2 imes i +1+ 1]).

  5. Replace the array nums with newNums.

  6. Repeat the entire process from step 11.

Return the final remaining value in nums after applying the algorithm.

Constraints:

  • 1≤1 \leq nums.length ≤1024\leq 1024

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • nums.length is a power of 22.