思路:我特喵的直接暴力解法

    1. /**
    2. * @param {number[]} nums
    3. * @return {number[]}
    4. */
    5. var sortArrayByParityII = function(nums) {
    6. let arr = []
    7. let arr_ou = []
    8. let arr_ji = []
    9. nums.forEach(data => {
    10. data % 2 === 0 ? arr_ou.push(data) : arr_ji.push(data)
    11. })
    12. for (let i = 0; i<arr_ji.length ;i++) {
    13. arr[i * 2] = arr_ou[i]
    14. arr[i * 2 + 1] = arr_ji[i]
    15. }
    16. return arr
    17. };

    image.png