public int[] getNext(char[] t){
        int[] next = new int[t.length];
        next[0] = -1;
        int i = 0;
        int j = -1;
        while(i < t.length-1){
            if(j == -1 || t[i] == t[j]){
                i++;
                j++;
                next[i] = j;
            }else{
                j = next[j];
            }
        }
        return next;
    }