MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / change

Function change

javascript/0518-coin-change-ii.js:8–16  ·  view source on GitHub ↗
(amount, coins, n = coins.length)

Source from the content-addressed store, hash-verified

6 * @return {number}
7 */
8var change = (amount, coins, n = coins.length) => {
9 const isBaseCase1 = amount === 0;
10 if (isBaseCase1) return 1;
11
12 const isBaseCase2 = n === 0;
13 if (isBaseCase2) return 0;
14
15 return dfs(amount, coins, n); /* Time O(2^N) | Space O(N) */
16};
17
18var dfs = (amount, coins, n) => {
19 const isLess = amount < coins[n - 1];

Callers 1

dfsFunction · 0.70

Calls 4

dfsFunction · 0.70
initMemoFunction · 0.70
initTabuFunction · 0.70
searchFunction · 0.70

Tested by

no test coverage detected