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.
Bottom up approach. First sort coins in ascending order. For each coin, we either take it or don't. If we don't take it, it is the value before. And if we take it, the i value must be greater than coin value and dp[i - coin] would have already been calculated so just add that.
The Coin Change Problem
You are viewing a single comment's thread. Return to all comments →
Bottom up approach. First sort coins in ascending order. For each coin, we either take it or don't. If we don't take it, it is the value before. And if we take it, the i value must be greater than coin value and dp[i - coin] would have already been calculated so just add that.