












枚举子集-求abc中所有子集
全排列问题
组合问题






// s:数组 ,需要求组合的集合// k:取出元素的个数function combination (S, k) {if (k === 0 || S.length === k) {return [S.slice(0, k)]}const [first, ...others] = Slet r = []r = r.concat(combination(others, k- 1).map(c=>[first, ...c]))r = r.concat(combination(others, k ))return r}const S = ['A','B','C','D' ]console.log(combination(S,2));
递归的空间优化
就是看能不能把递归转化成for循环,这样就可以避免循环调用引发的内存不足的问题
回溯算法

重复子问题优化
爬楼梯
尾递归
、


















