very easy approach, beats 98 %
IntuitionApproachComplexity
Time complexity:

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

# Approach


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

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

# Code
```java []
class Solution {
    public int[] sortArrayByParityII(int[] nums) {
        int ans [] = new int[nums.length];
        int evenIndex = 0;
        int oddIndex = 1;
        for(int i : nums){
            if(i % 2 == 0 ){
                ans[evenIndex] = i;
                evenIndex += 2;
            }
            if(i % 2 == 1){
                ans[oddIndex] = i;
                oddIndex += 2;
            }
           
        }  
        return ans;      
    }
}
```
['Java']