javascript coin change dp 113ms
\nconst mod = 1e9 + 7;\nconst cal = (c) => c == \'7\' || c == \'9\' ? 4 : 3\n\nconst countTexts = (s) => {\n    let n = s.length;\n    let dp = Array(n + 1).fil
```\nconst mod = 1e9 + 7;\nconst cal = (c) => c == \'7\' || c == \'9\' ? 4 : 3\n\nconst countTexts = (s) => {\n    let n = s.length;\n    let dp = Array(n + 1).fill(0);\n    dp[0] = 1;\n    for (let i = 0; i < n; i++) {\n        for (let j = 1; j <= cal(s[i]); j++) {\n            let len = i - j + 1;\n            if (len < 0 || s[i] != s[len]) break;\n            dp[i + 1] += dp[i + 1 - j];\n        }\n        dp[i + 1] %= mod;\n    }\n    return dp[n];\n};\n```
['Dynamic Programming', 'JavaScript']