(str, index = 0, memo = new Map())
| 7 | * @return {number} |
| 8 | */ |
| 9 | var 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 | |
| 21 | const dfs = (str, index, memo) => { |
| 22 | let count = numDecodings(str, index + 1, memo); |