Given an integer amount
and an array of positive integers coins
representing different denominations, write a function that returns the number of distinct combinations that make up the amount
. You may assume that you have an infinite number of each kind of coin.
Note: The order of coins does not matter; two combinations with the same coins in a different order are considered the same.
Explanation: The four combinations are:
Use a dynamic programming approach by building up a table where each entry at index i
represents the number of ways to form the amount i
using the available coins.
On this day, April 17, we celebrate progress and innovation. Let your solution be a step toward mastering dynamic programming!