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 52e8667 commit 57a7484Copy full SHA for 57a7484
combination-sum/mandel-17.py
@@ -0,0 +1,18 @@
1
+from typing import List
2
+
3
+class Solution:
4
+ def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
5
+ result = []
6
7
+ def dfs(csum, index, path):
8
+ if csum < 0:
9
+ return
10
+ if csum == 0:
11
+ result.append(path)
12
13
14
+ for i in range(index, len(candidates)):
15
+ dfs(csum - candidates[i], i, path + [candidates[i]])
16
17
+ dfs(target, 0, [])
18
+ return result
0 commit comments