You are viewing a single comment's thread. Return to all comments →
Simple Ruby DP solution:
def make_change(n, coins) dp = Array.new(n + 1, 0) dp[0] = 1 coins.each do |coin| (coin..n).each do |i| dp[i] += dp[i - coin] end end dp[n] end n, _m = gets.split.map(&:to_i) coins = gets.split.map(&:to_i) puts make_change(n, coins)
Seems like cookies are disabled on this browser, please enable them to open this website
DP: Coin Change
You are viewing a single comment's thread. Return to all comments →
Simple Ruby DP solution: