class Solution:
def change(self, amount: int, coins: List[int]) -> int:
dp = [float('inf')] * (amount + 1)
dp[0] = 1
for coin in coins:
for i in range(coin, amount + 1):
if dp[i - coin] != float('inf'):
dp[i] = dp[i] + dp[i - coin] if dp[i] != float('inf') else dp[i - coin]
return dp[-1] if dp[-1] != float('inf') else 0