C++ | Easy Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> sortArrayByParityII(vector<int>& nums) {\n        int even = 0 , odd=1;\n\t\t\t\tint n = nums.size() ;\n\t\t\t\twhile(even < n && odd < n){\n\t\t\t\t\tif(nums[even]%2==0){\n\t\t\t\t\t\teven += 2;\n\t\t\t\t\t}\n\t\t\t\t\tif(nums[odd]%2 == 1){\n\t\t\t\t\t\todd+=2;\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\tswap(nums[even],nums[odd]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nums;\n    }\n};\n```
['C++']