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 7fb7220 commit f1ba297Copy full SHA for f1ba297
combination-sum/sejineer.py
@@ -0,0 +1,15 @@
1
+"""
2
+시간 복잡도: O(target * n)
3
+공간 복잡도: O(n)?
4
+개인적으로 어려웠던 문제라서 정답을 봤습니다.
5
+추후에 다시 복습할 예정입니다.
6
7
+class Solution:
8
+ def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
9
+ dp = [[] for _ in range(target + 1)]
10
+ dp[0] = [[]]
11
+ for candidate in candidates:
12
+ for num in range(candidate, target + 1):
13
+ for combination in dp[num - candidate]:
14
+ dp[num].append(combination + [candidate])
15
+ return dp[target]
0 commit comments