Iam_Sandeep

Coin change, Reach a given score DP

May 6th, 2022
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1.  
  2. def count(n):
  3.     dp={}
  4.     arr=[3,5,10]
  5.     def help(coins,val):
  6.         if val==0:return 1
  7.         if coins<0 or val<0:return 0
  8.         if (coins,val) in dp:return dp[(coins,val)]
  9.         ans=0
  10.         ans+=help(coins,val-arr[coins])+help(coins-1,val)
  11.         dp[(coins,val)]=ans
  12.         return ans
  13.     return help(2,n)
Advertisement
Add Comment
Please, Sign In to add comment