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 2423497 commit 626fc9fCopy full SHA for 626fc9f
combination-sum/sungjinwi.py
@@ -0,0 +1,20 @@
1
+"""
2
+ 시간 복잡도와 공간복잡도 추후 작성하겠습니다ㅠ
3
+ 풀이 보고 하루 뒤에 기억해서 해보려고 했는데도 한참 걸렸네요
4
5
+class Solution:
6
+ def combinationSum(self, candidates: list[int], target: int) -> list[list[int]]:
7
+ ans = []
8
+ comb = []
9
+ def recur(n : int):
10
+ if sum(comb) > target :
11
+ return
12
+ elif sum(comb) == target :
13
+ return ans.append(comb.copy())
14
+ else :
15
+ for i in range(n, len(candidates)) :
16
+ comb.append(candidates[i])
17
+ recur(i)
18
+ comb.pop()
19
+ recur(0)
20
+ return ans
0 commit comments