public boolean isMatch(String s, String p) {
		int si = 0, pi = 0, match = 0, startpi = -1;
		while (si < s.length()) {
			// ? or matching, increase both pointer
			if (pi < p.length()
					&& (p.charAt(pi) == '?' || s.charAt(si) == p.charAt(pi))) {
				si++;
				pi++;
			}
			// * found, only increase pattern pointer
			else if (pi < p.length() && p.charAt(pi) == '*') {
				startpi = pi;
				match = si;
				pi++;
			}
			// last pattern pointer was *, increase string pointer
			else if (startpi != -1) {
				pi = startpi + 1;
				match++;
				si = match;
			}
			// current pointer is not *, last pattern pointer war not *
			else
				return false;
		}
		while (pi < p.length() && p.charAt(pi) == '*')
			pi++;
		return pi == p.length();
	}