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.
Others have downvoted the comment, and the reason why is that it is essentally the same solution as in the editorial. There are some additional test cases that the editorial doesn't have, but the logic is otherwise sound.
The reason it passes the runtime tests is because of the if (done[sum][numToUse] == -7) check. This ensures that we only compute solutions one time -- if we need the same solution again, we just use the previously computed solution.
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 →
Others have downvoted the comment, and the reason why is that it is essentally the same solution as in the editorial. There are some additional test cases that the editorial doesn't have, but the logic is otherwise sound.
The reason it passes the runtime tests is because of the if (done[sum][numToUse] == -7) check. This ensures that we only compute solutions one time -- if we need the same solution again, we just use the previously computed solution.