You are viewing a single comment's thread. Return to all comments →
Thanks for the good solution. I suggest a little improvement in the for cycle:
for(int i = coin; i < combinations.length; i++){ combinations[i] += combinations[i - coin]; }
Instead of iterating from 1 to amount value we start directly from the coin value and we don't need the if statement anymore.
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 →
Thanks for the good solution. I suggest a little improvement in the for cycle:
Instead of iterating from 1 to amount value we start directly from the coin value and we don't need the if statement anymore.