0
点赞
收藏
分享

微信扫一扫

[算法导论] 39. 组合总和

言午栩 2022-02-27 阅读 72
算法

0. 题目

1. 回溯

找出 无重复元素 的整数数组,组成target的所有可能。可以按 任意顺序 返回这些组合。

注意:

res.append(tmp[:]) #这里不能append动态变化的tmp!!!

class Solution(object):
    def combinationSum(self, candidates, target):
        candidates.sort()
        res = []
        # DFS [2,3,6,7] 7
        def backtrack(t,tmp,idx):
            if idx==len(candidates): #防止死循环
        
举报

相关推荐

0 条评论