C++ easy to understand step by step solution
\nclass Solution {\npublic:\n    vector<int> sortArrayByParityII(vector<int>& nums) {\n        \n        vector<int> result(nums.size());\n        int even=0,od
```\nclass Solution {\npublic:\n    vector<int> sortArrayByParityII(vector<int>& nums) {\n        \n        vector<int> result(nums.size());\n        int even=0,odd=1;\n        for(int i=0;i<nums.size();i++)\n        {\n            if(nums[i]%2==0)\n            {\n                result[even]=nums[i];\n                    even+=2;\n            }\n            else if(nums[i]%2!=0)\n            \n                {\n                    result[odd]=nums[i];\n                    odd+=2;\n                }\n            \n        }\n        return result;\n    }\n};\n```
['C', 'C++']