Python3 O(n) || O(1)
\nclass Solution:\n    def sortArrayByParityII(self, nums: List[int]) -> List[int]:\n        even, odd = 0, 1\n        \n        while even < len(nums) and odd 
```\nclass Solution:\n    def sortArrayByParityII(self, nums: List[int]) -> List[int]:\n        even, odd = 0, 1\n        \n        while even < len(nums) and odd < len(nums):\n            while even < len(nums) and nums[even] % 2 == 0:\n                even += 2\n            while odd < len(nums) and nums[odd] % 2 != 0:\n                odd += 2\n                \n            if even < len(nums) and odd < len(nums):\n                nums[even], nums[odd] = nums[odd], nums[even]\n                \n            even += 2\n            odd += 2\n        \n        return nums\n```
['Two Pointers', 'Python', 'Python3']