美文网首页
零钱兑换II

零钱兑换II

作者: yuriy0_0 | 来源:发表于2019-02-17 17:12 被阅读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]

相关文章

网友评论

      本文标题:零钱兑换II

      本文链接:https://www.haomeiwen.com/subject/eyogeqtx.html