Skip to content

Instantly share code, notes, and snippets.

@cixuuz
Created October 19, 2017 19:15
Show Gist options
  • Save cixuuz/f4408eb706be4b337494af0dd0e24c47 to your computer and use it in GitHub Desktop.
Save cixuuz/f4408eb706be4b337494af0dd0e24c47 to your computer and use it in GitHub Desktop.
[518. Coin Change 2] #leetcode
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