public boolean isMatch(String s, String p) {
        boolean[] a = new boolean[s.length()+1];
        boolean[] b = new boolean[s.length()+1];
        a[0] = true;
        for (int j=1; j<=s.length(); j++) a[j] = false;
        
        for (int i=1; i<=p.length(); i++) {
            char cp = p.charAt(i-1);
            b[0] = cp=='*' && a[0];
            for (int j=1; j<=s.length(); j++) {
                if (cp=='*') {
                    b[j] = a[j] || b[j-1];
                } else if (cp=='?') {
                    b[j] = a[j-1];
                } else {
                    b[j] = cp==s.charAt(j-1) && a[j-1];
                }
                
            }
            a = b;
        }
        return a[s.length()];
    }