Java | O(1) extra space | easy to understand
Please upvote if you like the solution\n\niterating until n>1\ntaking min of first to number and taking max of next to number, so on..\nmaintaining the index va
Please upvote if you like the solution\n\niterating until n>1\ntaking min of first to number and taking max of next to number, so on..\nmaintaining the index variable to indicate the current location where to store the new result i.e(min(a,b), max(a,b)\n\n```\nclass Solution {\n    public int minMaxGame(int[] nums) {\n        if(nums.length==1)\n            return nums[0];\n        int index = 0;\n        int n = nums.length;\n        int a=0,i=0;\n        while(n>1){\n            if(a%2==0){\n                nums[index] = Math.min(nums[i],nums[i+1]);\n                index++;\n                a++;\n            }\n            else{\n                nums[index] = Math.max(nums[i],nums[i+1]);\n                index++;\n                a++;\n            }\n            \n            if(i==n-2){\n                n=n/2;\n                index = 0;\n                a=0;\n                i=0;\n            }\n            else\n                i=i+2;\n        }\n        return nums[0];\n    }\n}\n```
['Java']