This file contains 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
#!/usr/bin/env node | |
// Solve the "Coin Change" problem using a bottom-up dynamic programming | |
// approach. The time complexity is O(n * coins.length) since we have a nested | |
// loop. The storage complexity is the same, as we store a matrix. | |
// | |
// * `coins` is an array of the coin values, eg. [ 1, 2, 3 ]. We assume it | |
// to be non-empty. | |
// * `n` is the amount, eg. 4 cents. | |
// |