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.
As I understand it, the variable coin_num begins counting at 1. So coin number 1 would be the first coin in the array, which is actually index 0, hence you must subtract 1 from coin_num. It just depends on how you define the variable. You could use count(sum-coins[coin_num],coins,coin_num), as long as it fits with the rest of your program.
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 →
As I understand it, the variable coin_num begins counting at 1. So coin number 1 would be the first coin in the array, which is actually index 0, hence you must subtract 1 from coin_num. It just depends on how you define the variable. You could use count(sum-coins[coin_num],coins,coin_num), as long as it fits with the rest of your program.