39. Combination Sum (Medium) - TengnanYao/daily_leetcode GitHub Wiki
class Solution(object):
def combinationSum(self, candidates, target):
"""
:type candidates: List[int]
:type target: int
:rtype: List[List[int]]
"""
self.result = []
def dfs(candidates, target, res):
if target == 0:
self.result.append(res)
for i in range(len(candidates)):
candi = candidates[i]
if candi <= target:
dfs(candidates[i : ], target - candi, res + [candi])
dfs(candidates, target, [])
return self.result