Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def change(self, amount: int, coins: List[int]) -> int:
- n=len(coins)
- m=amount
- dp=[[0]*(n+1) for i in range(m+1)]
- for i in range(m+1):#amount
- for j in range(n+1):#coins
- if i==0:
- dp[i][j]=1
- elif j==0:
- dp[i][j]=0
- else:
- excluded=dp[i][j-1]
- if i>=coins[j-1]:
- included=dp[i-coins[j-1]][j]
- print(included)
- dp[i][j]=included+excluded
- else:
- dp[i][j]=excluded
- for i in dp:
- print(i)
- return dp[-1][-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement