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 66335b3 commit 45ff2a2Copy full SHA for 45ff2a2
combination-sum/devyejin.py
@@ -0,0 +1,20 @@
1
+class Solution:
2
+ def combinationSum(self, candidates: list[int], target: int) -> list[list[int]]:
3
+
4
+ def backtracking(start, total, result):
5
+ if total == target:
6
+ answer.append(result[:])
7
+ return
8
9
+ if sum(result) > target:
10
11
12
+ for i in range(start, len(candidates)):
13
+ result.append(candidates[i])
14
+ backtracking(i, total + candidates[i], result)
15
+ result.pop()
16
17
+ answer = []
18
+ backtracking(0, 0, [])
19
+ return answer
20
0 commit comments