本文共 376 字,大约阅读时间需要 1 分钟。
var sortArrayByParityII = function(A) { let len = A.length; let arr0 = []; let arr1 = []; for(let i = 0; i < len; i++){ if(A[i]%2 == 0){ arr0.push(A[i]); }else{ arr1.push(A[i]); } } var i = 0; for(let j = 0; j < len; j++){ A[j] = arr0[i]; ++j; A[j] = arr1[i]; i++; } return A;};
转载地址:http://khtzi.baihongyu.com/