C++ Solution
\nclass Solution \n{\n    public:\n\tvector<int> sortArrayByParityII(vector<int>& nums) \n    {\n\t\tint n = nums.size();\n\t\tint i = 0, j = 1;\n\t\twhile(i < 
```\nclass Solution \n{\n    public:\n\tvector<int> sortArrayByParityII(vector<int>& nums) \n    {\n\t\tint n = nums.size();\n\t\tint i = 0, j = 1;\n\t\twhile(i < n && j < n)\n        {\n\t\t\tif(nums[i] % 2 == 0)\n            {\n\t\t\t\ti += 2;\n\t\t\t}\n\t\t\telse if(nums[j] % 2 == 1)\n            {\n\t\t\t\tj += 2;\n\t\t\t}\n\t\t\telse\n            {\n\t\t\t\tswap(nums[i], nums[j]);\n\t\t\t}\n\t\t}\n\t\treturn nums;\n\t}\n};\n```
['C', 'C++']