public int strStr(String haystack, String needle) {
        if (haystack == null || needle == null) return -1;
        if (needle.isEmpty()) return 0;
        int m = haystack.length(), n = needle.length();
        for (int i = 0; i < m - n + 1; ++i) {
            for (int j = 0; j < n; ++j) {
                if (needle.charAt(j) != haystack.charAt(i + j)) break;
                if (j == n - 1) return i;
            }
        }
        return -1;
    }