private void buildNext(String needle, int[] next){
        int j = 0, k = -1;
        next[0] = -1;
        while(j < needle.length() - 1){
            if(k == -1 || needle.charAt(j) == needle.charAt(k)){
                next[++j] = ++k;
            }else{
                k = next[k];
            }
        }
    }