思路:
******晚点写嘻嘻
代码:
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:
length = len(coins)
f = []
f.append(0) #初始化f(0) = 0
for i in range(1,amount+1):
temp = []
for j in range(0,length):
if i - coins[j] < 0:
temp.append(10**5)
else:
temp.append(f[i-coins[j]] + 1)
mins = min(temp)
f.append(mins)
if f[amount] >= 10**5:
return -1
else:
return f[amount]