2021-01-12 彩票全排列

function lottery(list) {
  // 输入list如[["1", "0"], ["1", "0"]]
    if (list.length == 0) {
        return [];
    }
    let res = list[0];
    for (let i = 1; i < list.length; i++) {
        const result = [];
        for (let j = 0; j < res.length; j++) {
            for (let k = 0; k < list[i].length; k++) {
                if (Array.isArray(res[j])) {
                  result.push([list[i][k], ...res[j]]);
                } else {
                  result.push([list[i][k], res[j]]);
                }
            }
        }
        res = result;
    }
    return res;
}

你可能感兴趣的:(2021-01-12 彩票全排列)