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

Function dfs

javascript/0091-decode-ways.js:21–31  ·  view source on GitHub ↗
(str, index, memo)

Source from the content-addressed store, hash-verified

19};
20
21const dfs = (str, index, memo) => {
22 let count = numDecodings(str, index + 1, memo);
23
24 if (isTwoDigit(str, index)) {
25 count += numDecodings(str, index + 2, memo);
26 }
27
28 memo.set(index, count);
29
30 return count;
31};
32
33var isTwoDigit = (str, index) => {
34 const twoDigit = Number(str.slice(index, index + 2));

Callers 1

numDecodingsFunction · 0.70

Calls 3

isTwoDigitFunction · 0.85
numDecodingsFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected