零钱兑换II

零钱兑换II_第1张图片
屏幕快照 2019-02-17 下午5.11.40.png
class Solution:
    def change(self, amount, coins):
        """
        :type amount: int
        :type coins: List[int]
        :rtype: int
        """
        dp=[0]*(amount+1)
        dp[0]=1
        for coin in coins:
            for i in range(amount+1):
                if i+coin<=amount:
                    dp[i+coin]+=dp[i]
        return dp[amount]

你可能感兴趣的:(零钱兑换II)