We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6a2d333 commit ae107c8Copy full SHA for ae107c8
combination-sum/printjin-gmailcom.py
@@ -0,0 +1,15 @@
1
+class Solution:
2
+ def combinationSum(self, candidates, target):
3
+ output, nums = [], []
4
+ def dfs(start, total):
5
+ if total > target:
6
+ return
7
+ if total == target:
8
+ return output.append(nums[:])
9
+ for i in range(start, len(candidates)):
10
+ num = candidates[i]
11
+ nums.append(num)
12
+ dfs(i, total + num)
13
+ nums.pop()
14
+ dfs(0, 0)
15
+ return output
0 commit comments