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 1c0b471 commit 03f2433Copy full SHA for 03f2433
coin-change/evan.py
@@ -0,0 +1,16 @@
1
+from typing import List
2
+
3
4
+class Solution:
5
+ def coinChange(self, coins: List[int], amount: int) -> int:
6
+ dp = [float("inf")] * (amount + 1)
7
+ dp[0] = 0
8
9
+ for currentAmount in range(1, amount + 1):
10
+ for coin in coins:
11
+ if currentAmount >= coin:
12
+ dp[currentAmount] = min(
13
+ dp[currentAmount], dp[currentAmount - coin] + 1
14
+ )
15
16
+ return dp[amount] if dp[amount] != float("inf") else -1
0 commit comments