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        \n        vector<int> ans(nums.size(),0);\n        int even=0;\n        int odd=1;\n\n        cout<<"Hello";\n        for(int i=0;i<nums.size();i++){\n            if(nums[i] % 2==0){\n                ans[even]=nums[i];\n                if(even+2 <= nums.size()-1){\n                    even+=2;\n                }\n                // cout<<ans[i]<<" ";\n            }\n            else{\n                ans[odd]=nums[i];\n                if(odd+2 <= nums.size()-1){\n                    odd+=2;\n                }\n                // cout<<ans[i]<<" ";\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']