I believe it is O(n) since i is always less than j and j is decreasing while i is increasing, but I want to make sure. Thanks!
/**
* @param {number[]} nums
* @return {number[]}
*/
var sortArrayByParity = function(nums) {
let j = nums.length-1;
for(let i = 0; i < nums.length && i < j; i++){
if(nums[i]%2){
for(; j > i; j--){
if(nums[j]%2 === 0){
let tempNum = nums[j]
nums[j] = nums[i]
nums[i] = tempNum
break;
}
}
}
}
return nums
};