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 96020a9 commit de096ecCopy full SHA for de096ec
โcombination-sum/Seoya0512.pyโ
@@ -0,0 +1,15 @@
1
+'''
2
+Approach
3
+- target๊ฐ์์ candidate ๊ฐ์ ๋นผ๊ณ ๊ทธ ๋์ ํฉ์ ์ฌ์ฉํด์ผํ๋ค๋ ํ๋ฆ์ ํ์ ํ์ง์ง๋ง ๊ตฌํ์ด ์ด๋ ค์ ์ต๋๋ค.
4
+-๊ทธ๋์ ์๊ณ ๋ฌ๋ ๋ฅผ ์ฐธ๊ณ ํด์ ์ต๋ํ ์ดํดํ๊ณ ํผ์ ์์ฑํด๋ณด๋ ค๊ณ ํ์ต๋๋ค....
5
6
+class Solution:
7
+ def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
8
+ dp = [[] for _ in range(target + 1)]
9
+ dp[0] = [[]]
10
+
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