Two Pointer | Java | O(n) runtime & O(1) space
\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        int left = 0, right = nums.length - 1;\n        while (left < right) {\n          
```\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        int left = 0, right = nums.length - 1;\n        while (left < right) {\n            if (nums[left] % 2 == 1) {\n                if (nums[right] % 2 == 0) {\n                    int temp = nums[left];\n                    nums[left] = nums[right];\n                    nums[right--] = temp;\n                } else {\n                    --right;\n                }\n            } else {\n                ++left;\n            }\n        }\n        return nums;\n    }\n}\n```
['Two Pointers', 'Java']