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 554a5ed commit b13a229Copy full SHA for b13a229
coin-change/KwonNayeon.py
@@ -0,0 +1,30 @@
1
+"""
2
+Constraints:
3
+1. 1 <= coins.length <= 12
4
+2. 1 <= coins[i] <= 2^31 - 1
5
+3. 0 <= amount <= 10^4
6
+
7
+Time Complexity: O(N*M)
8
+- N은 amount
9
+- M은 동전의 개수 (coins.length)
10
11
+Space Complexity: O(N)
12
13
14
+To Do:
15
+- DP 문제 복습하기
16
+- Bottom-up과 Top-down 방식의 차이점 이해하기
17
+- 그리디와 DP의 차이점 복습하기
18
19
20
+class Solution:
21
+ def coinChange(self, coins: List[int], amount: int) -> int:
22
+ dp = [sys.maxsize // 2] * (amount + 1)
23
+ dp[0] = 0
24
25
+ for i in range(1, amount + 1):
26
+ for coin in coins:
27
+ if i >= coin:
28
+ dp[i] = min(dp[i], dp[i-coin] + 1)
29
30
+ return dp[amount] if dp[amount] != sys.maxsize // 2 else -1
0 commit comments