public String strStr(String haystack, String needle) {
        if(needle.length()==0){
            return haystack;
        }
        if(haystack.length()<needle.length()){
            return null;
        }
        int[] ta = helper(needle);
        int i=0,m=0;
        while(i<needle.length()&&m+i<haystack.length()){
            if(haystack.charAt(m+i)==needle.charAt(i)){
                i++;
            }
            else{
                m=m-ta[i]+i;
                i=ta[i];
                if(i==-1){
                    i=0;
                }
            }
        }
        if(i==needle.length())
        {
            return haystack.substring(m);
        }
        else
            return null;
    }