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 864779b commit e0190f7Copy full SHA for e0190f7
coin-change/jeldo.py
@@ -0,0 +1,10 @@
1
+class Solution:
2
+ # O(n*m), n=len(coins), m=amount
3
+ def coinChange(self, coins: list[int], amount: int) -> int:
4
+ dp = [amount+1] * (amount+1)
5
+ dp[0] = 0
6
+ for i in range(amount+1):
7
+ for coin in coins:
8
+ if i - coin >= 0:
9
+ dp[i] = min(dp[i], dp[i-coin]+1)
10
+ return dp[amount] if dp[amount] != amount+1 else -1
0 commit comments