Python in 10 lines, simplest logic
Based on Kien_the_sun\'s code.  KMP makes this alot faster, but this is a good start to understanding some working code.\n\n\ndef findGoodStrings(self, N, *args
Based on Kien_the_sun\'s code.  KMP makes this alot faster, but this is a good start to understanding some working code.\n\n```\ndef findGoodStrings(self, N, *args) :\n    s1,s2, evil = [list(map(ord, i)) for i in args]\n    def length(l, ch):\n        i = 0\n        while i <= l and not evil[i:l] + [ch] == evil[:l-i+1]: i += 1\n        return l-i + 1\n\n    @lru_cache(None)\n    def dp(i = 0, l = 0 , f1 = False, f2 = False):\n        if l == len(evil): return 0 \n        if i == N : return 1\n        return sum(dp(i+1, length(l, ch), f1 or ch > s1[i], f2 or ch < s2[i])\n                   for ch in range(f1 and 97 or s1[i], f2 and 123 or s2[i]+1))\n\n    return dp() % (10 ** 9 + 7)\n```
[]