@@ -0,0 +1,1506 @@
+package me.dslztx.assist.algorithm;%0A%0A// TODO%0Apublic class KMP %7B%0A%0A    String pattern;%0A%0A    int%5B%5D fail;%0A%0A    int%5B%5D longestCommon;%0A%0A    public KMP(String pattern) %7B%0A        this.pattern = pattern;%0A%0A        buildFail();%0A%0A        // buildFailOptimize();%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        // KMP kmp = new KMP();%0A        // kmp.t = %22ABCDABD%22.toCharArray();%0A        //%0A        // kmp.lent = 7;%0A        // kmp.nextval = new int%5B8%5D;%0A        //%0A        // System.out.println(%22hello world%22);%0A    %7D%0A%0A    public boolean match(String str) %7B%0A        return false;%0A    %7D%0A%0A    public int firstMatchIndex(String str) %7B%0A        return -1;%0A    %7D%0A%0A    public int%5B%5D wholeMatchIndexes(String str) %7B%0A        return null;%0A    %7D%0A%0A    private void buildFailOptimize() %7B%7D%0A%0A    private void buildFail() %7B%0A        longestCommon = new int%5Bpattern.length()%5D;%0A%0A        longestCommon%5B0%5D = 0;%0A%0A        int len;%0A        for (int i = 1; i %3C pattern.length(); i++) %7B%0A%0A            len = longestCommon%5Bi - 1%5D;%0A            while (len %3E 0 && pattern.charAt(len) != pattern.charAt(i)) %7B%0A                len = longestCommon%5Blen - 1%5D;%0A            %7D%0A%0A            if (pattern.charAt(len) != pattern.charAt(i)) %7B%0A                longestCommon%5Bi%5D = 0;%0A            %7D else %7B%0A                longestCommon%5Bi%5D = len + 1;%0A            %7D%0A        %7D%0A%0A        fail = new int%5Bpattern.length()%5D;%0A%0A        for (int i = pattern.length() - 1; i %3E= 1; i--) %7B%0A            fail%5Bi%5D = longestCommon%5Bi - 1%5D;%0A        %7D%0A%0A        fail%5B0%5D = -1;%0A    %7D%0A%0A%7D%0A

add KMP