Created
October 19, 2017 19:15
-
-
Save cixuuz/f4408eb706be4b337494af0dd0e24c47 to your computer and use it in GitHub Desktop.
[518. Coin Change 2] #leetcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def change(self, amount, coins): | |
""" | |
:type amount: int | |
:type coins: List[int] | |
:rtype: int | |
""" | |
# dp placeholder | |
dp = [0] * (amount+1) | |
dp[0] = 1 | |
for i in coins: | |
for j in range(1, amount+1): | |
if j - i >= 0: | |
dp[j] += dp[j-i] | |
return dp[amount] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment