JS
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nvar findGoodStrings = function(n, s1, s2, evil) {\n    const evilLen = evil.length;\n    const mod = 1000000007\n    const kmp = buildKmpArray(evil);\n    \n    const cache = {};\n    const cnt = (sIdx, evilIdx, isPrefixOf1, isPrefixOf2) => {\n        if (evilIdx === evilLen) return 0;\n        if (sIdx === n) return 1;\n        const key = [sIdx, evilIdx, isPrefixOf1, isPrefixOf2].join(\'-\');\n        if (cache.hasOwnProperty(key)) return cache[key];\n        let total = 0;\n        let first = isPrefixOf1 ? s1.charCodeAt(sIdx) : 97  // a;\n        let last = isPrefixOf2 ? s2.charCodeAt(sIdx) : 122  // z;\n        for (let i = first; i <= last; i++) {\n            const char = String.fromCharCode(i);\n            const isPre1 = isPrefixOf1 && i === first;\n            const isPre2 = isPrefixOf2 && i === last;\n            let evilPrefix = evilIdx;\n            while (evilPrefix && char !== evil[evilPrefix]) {\n                evilPrefix = kmp[evilPrefix - 1];\n            }\n            if (char === evil[evilPrefix]) {\n                evilPrefix += 1;\n            }\n            total += cnt(sIdx + 1, evilPrefix, isPre1, isPre2);\n        }\n        return cache[key] = total % mod;\n    }\n    return cnt(0, 0, true, true);\n};\n\nfunction buildKmpArray(str) {\n    const result = new Array(str.length).fill(0);\n    let j = 0;\n    for (let i = 1; i < str.length; i++) {\n        while (j && str[j] !== str[i]) {\n            j = result[j - 1];\n        }\n        if (str[i] === str[j]) {\n            j += 1;\n        }\n        result[i] = j;\n    }\n    return result;\n}\n```
['JavaScript']