문제 링크 : Sort Array By Parity II
/**
* @param {number[]} nums
* @return {number[]}
*/
var sortArrayByParityII = function(nums) {
const result = new Array(nums.length).fill(0);
let oddCur = 1
let evenCur = 0
for(let i=0; i<nums.length; i++) {
if(nums[i]%2) {
result[oddCur] = nums[i]
oddCur +=2
}else {
result[evenCur] = nums[i]
evenCur +=2
}
}
return result
};