✅ Easy C++ Solution
Code\n\nclass Solution {\npublic:\n    vector<int> sortArrayByParityII(vector<int>& nums) {\n        int even = 0;\n        int odd = 1;\n        int n = nums.s
# Code\n```\nclass Solution {\npublic:\n    vector<int> sortArrayByParityII(vector<int>& nums) {\n        int even = 0;\n        int odd = 1;\n        int n = nums.size();\n        vector<int> v(n);\n        for(int i=0;i<n;i++)\n        {\n            if(nums[i] % 2 == 0)\n            {\n                v[even] = nums[i];\n                even = even + 2;\n            }\n            else\n            {\n                v[odd] = nums[i];\n                odd = odd + 2;\n            }\n        }\n        return v;\n    }\n};\n```
['C++']