Created
July 6, 2021 18:19
-
-
Save Shaddyjr/9b26a4cc15c7bde2e603c83ac0085b90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source: https://www.hackerrank.com/challenges/coin-change | |
// video: https://www.youtube.com/watch?v=b34GYbwwrJ8 | |
function getWays(n, c) { | |
const store = new Array(n + 1).fill(0); | |
store[0] = 1; | |
for(const coin of c){ | |
for(let total = coin; total < store.length; total++){ | |
const remainder = total - coin; | |
store[total] += store[remainder]; | |
} | |
} | |
return store[n]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment