[Python手撕]零钱兑换(组合总数,需要去重)
class Solution:
def change(self, amount: int, coins: List[int]) -> int:
dp = [0]*(amount+1)
dp[0] = 1
# 从面值开始遍历是为了去重
for c in coins:
for i in range(c,amount+1):
dp[i] += dp[i-c]
return dp[-1]