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 b9e028d commit bd7c413Copy full SHA for bd7c413
combination-sum/HodaeSsi.py
@@ -0,0 +1,16 @@
1
+# 시간복잡도 : O(n * m) (n: target, m: len(candidates))
2
+# 공간복잡도 : O(n * m)
3
+class Solution:
4
+ def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
5
+ dp = [[] for _ in range(target + 1)]
6
+ dp[0] = [[]]
7
+
8
+ for candidate in candidates:
9
+ for num in range(candidate, target + 1):
10
+ for combination in dp[num - candidate]:
11
+ temp = combination.copy()
12
+ temp.extend([candidate])
13
+ dp[num].append(temp)
14
15
+ return dp[target]
16
0 commit comments