[Python] Single loop (extend the list)
A few variations of the same idea: Append the computed min/max values to the given list. That way I just need one "loop", because at the end of the originally g
A few variations of the same idea: Append the computed min/max values to the given list. That way I just need *one* "loop", because at the end of the originally given data, I then encounter and continue with the min/max values I computed. At the end, I just return the last value.\n\n```python\n# New version in 2024\ndef minMaxGame(self, nums: List[int]) -> int:\n    it = iter(nums)\n    nums += map(call, cycle((min, max)), it, it)\n \xA0  return nums[-1]\n```\n```python\n# 2025 version? :-) When LeetCode gets Python 3.12\ndef minMaxGame(self, nums: List[int]) -> int:\n    nums += map(call, cycle((min, max)), batched(nums, 2))\n    return nums[-1]\n```\n\n    def minMaxGame(self, nums: List[int]) -> int:\n        it = iter(nums)\n        for f, *x in zip(cycle((min, max)), it, it):\n            nums.append(f(*x))\n        return nums[-1]\n\n    def minMaxGame(self, nums: List[int]) -> int:\n        def minmax(*x, f=cycle((min, max))):\n            return next(f)(*x)\n        it = iter(nums)\n        nums += map(minmax, it, it)\n        return nums[-1]\n    \n    def minMaxGame(self, nums: List[int]) -> int:\n        it = iter(nums)\n        nums += map(lambda f, *x: f(*x), cycle((min, max)), it, it)\n        return nums[-1]\n    \n    def minMaxGame(self, nums: List[int]) -> int:\n        it = iter(nums)\n        nums += (f(*x) for f, *x in zip(cycle((min, max)), it, it))\n        return nums[-1]\n        \n    def minMaxGame(self, nums: List[int]) -> int:\n        it = iter(nums)\n        for i, x in enumerate(it):\n            try:\n                nums.append((min, max)[i%2](x, next(it)))\n            except:\n                return x\n\n    def minMaxGame(self, nums: List[int]) -> int:\n        it = iter(nums)\n        nums += chain.from_iterable(\n            zip(map(min, it, it),\n                map(max, it, it)))\n        return min(nums[-2:])\n\n
[]