public String strStr(String haystack, String needle) {
        if(needle.length() ==0)
            return haystack;
        int [] next = getNext(needle.toCharArray());
        int i = 0;
        int j = 0;
        while(i < haystack.length()){
            if(j == -1 || haystack.charAt(i)== needle.charAt(j)){
                i++;
                j++;
            }else {
                j = next[j];
            }
            if(j == needle.length())
                return haystack.substring(i - needle.length(),haystack.length());
        }

        return null;

    }