beats 100 and 91 % in runtime and memory , Python3 code
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```\nclass Solution:\n    def findGoodStrings(self, n: int, s1: str, s2: str, evil: str) -> int:\n        p=10**9+7\n        ord_a=ord(\'a\')\n        l=len(evil)\n        dup=[]\n        for i in range(1, l):\n            if evil[i:]==evil[:l-i]:\n                dup.append(i)\n        lend=len(dup)\n        def count(s):\n            tmp_ct=0\n            bd=1\n            ind=n\n            without_s=[]\n            for i in range(n):\n                tmp_ct*=26\n                if bd:\n                    tmp_ct+=ord(s[i])-ord_a\n                if i>=l-1 and ind>i-l and evil<s[i-l+1:i+1]:\n                    tmp_ct-=1\n                if i>=l:\n                    tmp_ct-=without_s[i-l]\n                if i>=l-1:\n                    if s[i-l+1:i+1]==evil:\n                        bd=0\n                        ind=i\n                tmp_ct%=p\n                tmp_with_s=0\n                for j in range(lend):\n                    d=dup[j]\n                    if i>=d:\n                        tmp_with_s+=without_s[i-d]\n                    if i>=d-1 and ind>i-d and evil[:d]<s[i-d+1:i+1]:\n                        tmp_with_s+=1\n                without_s.append(tmp_ct-tmp_with_s)\n            return tmp_ct, bd\n        str_ct1, bd1=count(s1)\n        str_ct2, bd2=count(s2)\n        return (str_ct2-str_ct1+bd2)%p\n```
['Python3']