We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
value,_=map(int,raw_input().strip().split(' '))coins=map(int,raw_input().strip().split(' '))ways=[0]*(value+1)forcoinincoins:ifcoin>value:#if coin > value, there's no reason to use itcontinueways[coin]+=1#coin by itself as a setforiinrange(coin+1,value+1):#fill the remaining sets with a new possibility with this coin ways[i]+=ways[i-coin]printways[value]
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Coin Change Problem
You are viewing a single comment's thread. Return to all comments →
DP in python2 with 1D list/array: