var combinationSum3 = function(k, n) {
let arr=[]
let p=[]
const dd=function(k,n,index,sum){
//中止条件
if(p.length==k){
if(sum==n){
arr.push([...p])
return
}
}
for(let i=index;i<=9;i++){
p.push(i)
sum+=i
dd(k,n,i+1,sum)
//回溯
sum-=i
p.pop()
}
}
dd(k,n,1,0)
return arr
};
06-22
1548
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-19
131
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-12
525
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-22
590
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-22
210
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-13
305
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-13
281
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)