零钱兑换II

2019-02-17  本文已影响0人  yuriy0_0
屏幕快照 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]
上一篇下一篇

猜你喜欢

热点阅读