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 cf0b643 commit 59c596aCopy full SHA for 59c596a
coin-change/HodaeSsi.py
@@ -0,0 +1,17 @@
1
+# space complexity: O(n) (여기서 n은 amount)
2
+# time complexity: O(n * m) (여기서 n은 amount, m은 coins의 길이)
3
+from typing import List
4
+
5
6
+class Solution:
7
+ def coinChange(self, coins: List[int], amount: int) -> int:
8
+ dp = [float('inf')] * (amount + 1)
9
+ dp[0] = 0
10
11
+ for i in range(1, amount + 1):
12
+ for coin in coins:
13
+ if coin <= i:
14
+ dp[i] = min(dp[i], dp[i - coin] + 1)
15
16
+ return dp[amount] if dp[amount] != float('inf') else -1
17
0 commit comments