class Solution {
public int[] sortArrayByParityII(int[] A) {
int el=0;
int ol=1;
int len=A.length;
int[] ans=new int[len];
for(int i=0;i<len;++i){
if(A[i]%2==0){
ans[el]=A[i];
el+=2;
}
else{
ans[ol]=A[i];
ol+=2;
}
}
return ans;
}
}