[Python] Two Pointers - O(1) Space - Clean & Concise
Idea\n- Let iEven point to the first number which has an even index but the value is odd.\n- Let iOdd point to the first number which has an odd index but the v
**Idea**\n- Let `iEven` point to the first number which has an even index but the value is odd.\n- Let `iOdd` point to the first number which has an odd index but the value is even.\n- We need to swap `nums[iEven]` and `nums[iOdd]` together since they are mismatch.\n```python\nclass Solution:\n    def sortArrayByParityII(self, nums: List[int]) -> List[int]:\n        n = len(nums)\n        iEven = 0\n        iOdd = 1\n        while True:\n            while iEven < n and nums[iEven] % 2 == 0:\n                iEven += 2\n            while iOdd < n and nums[iOdd] % 2 == 1:\n                iOdd += 2\n            if iEven >= n or iOdd >= n:\n                break\n\n            nums[iEven], nums[iOdd] = nums[iOdd], nums[iEven]\n            iEven += 2\n            iOdd += 2\n        return nums\n```\nComplexity:\n- Time: `O(N)`, where `N <= 2*10^4` is length of `nums` array.\n- Space: `O(1)`
[]