Very Intuitive Python Memoized solution (uses KMP).
\nclass Solution:\n    def findGoodStrings(self, n: int, s1: str, s2: str, evil: str) -> int:\n        \n        def kmp():\n            for i in range(1, sz):\
```\nclass Solution:\n    def findGoodStrings(self, n: int, s1: str, s2: str, evil: str) -> int:\n        \n        def kmp():\n            for i in range(1, sz):\n                j = prefix[i-1]\n                while j != 0 and evil[i] != evil[j]:\n                    j = prefix[j-1]\n                prefix[i] = j+1 if evil[i]==evil[j] else 0\n        \n        def recurse(i, greater, smaller, ei):\n\t\t\'\'\' i  represents the ith character of good string.\n\t\t  We\'re just trying to enumerate all possible characters for i. It\'s limited by the characters 0..i-1 that\n\t\t  we\'ve already chosen. If this prefix is already greater than s1 we can choose any character else it\n\t\t  should be >= s1[i]. Similar reasoning for smaller. Finally, we should make sure that evil\n\t\t  is not be a substring. So we have "ei". It implies that the last few characters we\'ve \n\t\t  chosen match with evil[0:ei]. So, if the character we choose here matches evil[ei] we increment ei \n\t\t  by 1, else we find the longest prefix of evil that is also a suffix of evil[0..ei]. We can use our KMP\'s \n\t\t  preprocessed prefix array here.\n\t\t  \'\'\'\n            key = (i, greater, smaller, ei) \n            if key in dp:\n                res = dp[key]\n            elif ei == len(evil):\n                res = 0\n            elif i == n:\n                res = 1\n            else:\n                c1, c2, c3 = s1[i], self.s2[i], evil[ei]\n                \n                a, z = ord(\'a\'), ord(\'z\')\n                st = a if greater else ord(c1)\n                chars1 = range(st, z+1)\n                end = z if smaller else ord(c2)\n                chars2 = range(a, end+1)\n                \n                chars = set(chars1) & set(chars2)\n                res = 0\n                for ch in chars:\n                    c = chr(ch)\n                    ei2 = ei\n                    while ei2 != 0 and evil[ei2] != c:\n                        ei2 = prefix[ei2-1]\n                    ei2 = (ei2+1) if c==evil[ei2] else 0\n                        \n                    g2 = greater or (c > c1)\n                    s2 = smaller or (c < c2)\n                    res += recurse(i+1, g2, s2, ei2)\n                    res %= MOD\n            dp[key] = res\n            return res\n        \n        if s1 > s2:\n            return 0\n        \n        dp = {}\n        MOD = 10**9 + 7\n        self.s2 = s2\n        sz = len(evil)\n        prefix = [0] * sz\n        kmp()\n        return recurse(0, False, False, 0)\n```
[]