Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cointotal(amount,coins):
- dp = [amount+1]*(amount+1)
- dp[0] = 0
- for a in range(1,amount+1):
- for c in coins:
- if a-c >=0:
- dp[a] = min(dp[a],1+dp[a-c])
- return dp[amount]
- amount = 7
- coins = [1,3,4,5]
- print(cointotal(amount,coins))
- #Refer video
- #https://www.youtube.com/watch?v=H9bfqozjoqs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement