✅ Easy C++ Solution
Code\n\nclass Solution {\npublic:\n    vector<int> sortArrayByParity(vector<int>& nums) {\n        int n = nums.size();\n        int i = 0;\n        int j = n -
# Code\n```\nclass Solution {\npublic:\n    vector<int> sortArrayByParity(vector<int>& nums) {\n        int n = nums.size();\n        int i = 0;\n        int j = n - 1;\n        while(i < j)\n        {\n            if(nums[i] % 2 != 0 && nums[j] % 2 == 0)\n            {\n                swap(nums[i],nums[j]);\n                i++;\n                j--;\n            }\n            else if(nums[i] % 2 != 0)\n            {\n                j--;\n            }\n            else if(nums[j] % 2 == 0)\n            {\n                i++;\n            }\n            else\n            {\n                i++;\n                j--;\n            }\n        }\n        return nums;\n    }\n};\n```
['C++']