🌻Easiest [C++/Java] 3 Liner code || Two pointer intuitive || Fast & Simple
Please Upvote if you Like it :)\n\nTC: O(N)\nSC: O(1)\n\nC++\n\nclass Solution {\npublic:\n    vector<int> sortArrayByParity(vector<int>& nums) {\n        for (
**Please Upvote if you Like it :)**\n\n**TC: O(N)\nSC: O(1)**\n\n**C++**\n```\nclass Solution {\npublic:\n    vector<int> sortArrayByParity(vector<int>& nums) {\n        for (int i = 0, j = 0; j < nums.size(); j++)\n            if (nums[j] % 2 == 0) swap(nums[i++], nums[j]);\n        return nums;\n    }\n};\n```\n\n\n\n**JAVA**\n```\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        for (int i = 0, j = 0; j < nums.length; j++)\n            if (nums[j] % 2 == 0) {\n                int temp = nums[i];\n                nums[i++] = nums[j];\n                nums[j] = temp;\n            }\n        return nums;\n    }\n}\n```
['Two Pointers', 'C', 'Java']