C++[Easy to understand & simple logic]
IntuitionApproachComplexity
Time complexity:
O[n]

Space complexity:
O[n]
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
- O[n]
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
- O[n]
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```
class Solution {
public:
    vector<int> sortArrayByParityII(vector<int>& nums) {
    
        vector<int> ans(nums.size());
        int e=0,o=1;
        for(int i=0;i<nums.size();i++)
        {
            if(nums[i]%2==0)
            {
                ans[e]=nums[i];
                    e+=2;
            }
            else if(nums[i]%2!=0)
            
                {
                    ans[o]=nums[i];
                    o+=2;
                }
            
        }
        return ans;
    }
};
['C++']