🏆💢💯 Faster✅💯 Lesser🧠 🎯 C++✅Python3🐍✅Java✅C✅Python🐍✅💥🔥💫Explained☠💥🔥 Beats 💯
Intuition\n\n\n\nC++ []\nclass Solution {\npublic:\n    int minMaxGame(vector<int>& nums) {\n        if (nums.size() == 1)\n            return nums[0];\n       
# Intuition\n![0ehh83fsnh811.jpg](https://assets.leetcode.com/users/images/1a744db2-4b53-4afc-8c01-4a6c15230828_1717120757.1913037.jpeg)\n![Screenshot 2024-05-31 071155.png](https://assets.leetcode.com/users/images/bca9ae3a-53fb-4169-b4ea-51a956960638_1717120766.4883938.png)\n![Screenshot 2024-05-31 072840.png](https://assets.leetcode.com/users/images/941946ab-850e-4ea5-9518-8aba4736efb0_1717120772.6659195.png)\n```C++ []\nclass Solution {\npublic:\n    int minMaxGame(vector<int>& nums) {\n        if (nums.size() == 1)\n            return nums[0];\n        vector<int> newNums;\n        for (int i = 0; i < nums.size() / 2; ++i) {\n            if (i % 2 == 0)\n                newNums.push_back(min(nums[2 * i], nums[2 * i + 1]));\n            else\n                newNums.push_back(max(nums[2 * i], nums[2 * i + 1]));\n        }\n        return minMaxGame(newNums);\n    }\n};\n```\n```python3 []\nclass Solution:\n    def minMaxGame(self, nums: List[int]) -> int:\n        if len(nums) == 1:\n            return nums[0]\n        new_nums = []\n        for i in range(len(nums) // 2):\n            if i % 2 == 0:\n                new_nums.append(min(nums[2 * i], nums[2 * i + 1]))\n            else:\n                new_nums.append(max(nums[2 * i], nums[2 * i + 1]))\n        return self.minMaxGame(new_nums)\n```\n```C []\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n\nint minMaxGame(int* nums, int numsSize) {\n    while (numsSize > 2) {\n        for (int i = 0, j = 0; i < numsSize; i += 4, j += 2) {\n            nums[j] = MIN(nums[i], nums[i + 1]);\n            nums[j + 1] = MAX(nums[i + 2], nums[i + 3]);\n        }\n        numsSize >>= 1;\n    }\n    return (numsSize != 1) ? MIN(nums[0], nums[1]) : nums[0];\n}\n```\n```Java []\nclass Solution {\n    public int minMaxGame(int[] nums) {\n        if (nums.length == 1)\n            return nums[0];\n        List<Integer> newNums = new ArrayList<>();\n        for (int i = 0; i < nums.length / 2; i++)\n            if (i % 2 == 0)\n                newNums.add(Math.min(nums[2 * i], nums[2 * i + 1]));\n            else\n                newNums.add(Math.max(nums[2 * i], nums[2 * i + 1]));\n        \n        return minMaxGame(newNums.stream().mapToInt(i -> i).toArray());\n    }\n}\n```\n```python []\nclass Solution(object):\n    def minMaxGame(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: int\n        """\n        n = len(nums)\n        while n > 1:\n            newNums = []\n            for i in range(n // 2):\n                if i % 2 == 0:\n                    newNums.append(min(nums[2 * i], nums[2 * i + 1]))\n                else:\n                    newNums.append(max(nums[2 * i], nums[2 * i + 1]))\n            nums = newNums\n            n = len(nums)\n        return nums[0]\n```\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n     O(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n     O(n / 2)\n# Code\n```\nclass Solution {\n    public int minMaxGame(int[] nums) {\n        if (nums.length == 1)\n            return nums[0];\n        List<Integer> newNums = new ArrayList<>();\n        for (int i = 0; i < nums.length / 2; i++)\n            if (i % 2 == 0)\n                newNums.add(Math.min(nums[2 * i], nums[2 * i + 1]));\n            else\n                newNums.add(Math.max(nums[2 * i], nums[2 * i + 1]));\n        \n        return minMaxGame(newNums.stream().mapToInt(i -> i).toArray());\n    }\n}\n```\n# ***Please Upvote if it\'s useful***\n![th.jpeg](https://assets.leetcode.com/users/images/d0650dbd-f4d0-4907-9198-be18c8425e44_1717120911.613003.jpeg)\n
['Array', 'Hash Table', 'Math', 'C', 'Simulation', 'Python', 'C++', 'Java', 'Python3']