获取列表中所有满足条件的组合,组合的元素经过转换后的总和等于目标值 包含从1个元素到指定最大数量的所有可能组合
源列表
转换函数,将列表元素转换为数值
目标总和
组合中元素的最大数量
所有满足条件的组合数组
const list = [1, 2, 3, 4, 5];const groups = listGroupSumAll(list, x => x, 5, 3);// 返回[[5], [1,4], [2,3]] Copy
const list = [1, 2, 3, 4, 5];const groups = listGroupSumAll(list, x => x, 5, 3);// 返回[[5], [1,4], [2,3]]
获取列表中所有满足条件的组合,组合的元素经过转换后的总和等于目标值 包含从1个元素到指定最大数量的所有可能组合