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

Function numDecodings

javascript/0091-decode-ways.js:9–19  ·  view source on GitHub ↗
(str, index = 0, memo = new Map())

Source from the content-addressed store, hash-verified

7 * @return {number}
8 */
9var numDecodings = (str, index = 0, memo = new Map()) => {
10 const isBaseCase1 = !str.length || str[index] === '0';
11 if (isBaseCase1) return 0;
12
13 const isisBaseCase2 = index === str.length;
14 if (isisBaseCase2) return 1;
15
16 if (memo.has(index)) return memo.get(index);
17
18 return dfs(str, index, memo);
19};
20
21const dfs = (str, index, memo) => {
22 let count = numDecodings(str, index + 1, memo);

Callers 1

dfsFunction · 0.70

Calls 4

dfsFunction · 0.70
getTabuFunction · 0.70
decodeFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected