Java Easy Solution
\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        for (int i = 0, j = nums.length - 1; i < j;) {\n            if (nums[i] % 2 == 1) 
```\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        for (int i = 0, j = nums.length - 1; i < j;) {\n            if (nums[i] % 2 == 1) {\n                int x = nums[i];\n                nums[i] = nums[j];\n                nums[j] = x;\n                --j;\n            } else {\n                ++i;\n            }\n        }\n        return nums;\n    }\n}\n```
['Java']