Can anybody help to see why this Java DP not work without KMP ?
\nclass Solution {\n    private String s1;\n    private String s2;\n    private String evil;\n    \n    private int helper(int[][][][] dp, int curr_pos, int evi
```\nclass Solution {\n    private String s1;\n    private String s2;\n    private String evil;\n    \n    private int helper(int[][][][] dp, int curr_pos, int evil_pos, int low_limit, int high_limit) {\n        if(curr_pos == s1.length()) {\n            return evil_pos == evil.length() ? 0 : 1;\n        } else if(evil_pos == evil.length()) {\n            return 0;\n        }\n        \n        if(dp[curr_pos][evil_pos][low_limit][high_limit] > 0) {\n            return dp[curr_pos][evil_pos][low_limit][high_limit];\n        }\n        \n        char lower = low_limit > 0 ? s1.charAt(curr_pos) : \'a\';\n        char upper = high_limit > 0 ? s2.charAt(curr_pos) : \'z\';\n        char evilc = evil.charAt(evil_pos);\n        \n        int res = 0;\n        for(char c = lower; c <= upper; c++) {\n            if(c == lower && c == upper) {\n                res += helper(dp, curr_pos+1, c == evilc ? evil_pos+1 : 0, 1, 1);\n            } else if (c == lower) {\n                res += helper(dp, curr_pos+1, c == evilc ? evil_pos+1 : 0, low_limit, 0);\n            } else if (c == upper) {\n                res += helper(dp, curr_pos+1, c == evilc ? evil_pos+1 : 0, 0, high_limit);\n            } else {\n                res += helper(dp, curr_pos+1, c == evilc ? evil_pos+1 : 0, 0, 0);\n            }\n            res %= (1e9+7);\n        }\n        dp[curr_pos][evil_pos][low_limit][high_limit] = res;\n        return res;\n    }\n    \n    public int findGoodStrings(int n, String s1, String s2, String evil) {\n        this.s1 = s1;\n        this.s2 = s2;\n        this.evil = evil;\n        \n        int[][][][] dp = new int[s1.length()][evil.length()][2][2];\n        return helper(dp, 0, 0, 1, 1);\n    }\n}\n```
[]