1def coinChange(self, coins: List[int], amount: int) -> int:
2 if amount == 0:
3 return 0
4
5 cols = amount + 1
6 T = [0 if idx == 0 else float('inf') for idx in range(cols)]
7
8 for j in range(len(coins)):
9 for i in range(1, cols):
10 coin = coins[j]
11 if(i >= coins[j]):
12 T[i] = min(T[i], T[i - coin] + 1)
13
14 return -1 if (T[-1] == float('inf')) else T[-1]
15