📜  组合求和问题 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:15.206000             🧑  作者: Mango

代码示例1
var targetArray = function(nums, target) {
    var res = [];
    var dfs = function(path,start) {
        if(sum(path) === target) {                  //(1)
            res.push([...path]);
            return;
        }
        if(sum(path) > target) {
            return;
        }
        for(let i=start; ia+b)
}

console.log(targetArray([2,3,5],8))
// [ [ 2, 2, 2, 2 ], [ 2, 3, 3 ], [ 3, 5 ] ]