public static String strStr(String haystack, String needle) {//accepted
        if (needle == null || haystack == null) return null;
        if (haystack.equals(needle)) return haystack;
        if (needle == "") {
            return haystack;
        }
        if (haystack == "") {
            return null;
        }
        int n_len = needle.length();
        int h_len = haystack.length();
        char h_arr[] = haystack.toCharArray();
        char n_arr[] = needle.toCharArray();
        for (int i = 0; i < h_len - n_len; ++i) {
            int j = 0;
            for (; j < n_len; ++j) {
                if (h_arr[i+j] != n_arr[j]) {
                    break;
                }
            }
            if (j == n_len) {
                return haystack.substring(i);
            }
        }
        return null;
    }