My Java DP Solution
At first I cannot pass the the long 'aaa...' test case. Then I add more check and pass it.\n\n    public class Solution {\n        public boolean isMatch(String
At first I cannot pass the the long 'aaa...' test case. Then I add more check and pass it.\n\n    public class Solution {\n        public boolean isMatch(String s, String p) {\n            int m = s.length(), n = p.length();\n            int count = 0;\n            for (int i = 0; i < n; i++) {\n                if (p.charAt(i) == '*') count++;\n            }\n            if (count==0 && m != n) return false;\n            else if (n - count > m) return false;\n            \n            boolean[] match = new boolean[m+1];\n            match[0] = true;\n            for (int i = 0; i < m; i++) {\n                match[i+1] = false;\n            }\n            for (int i = 0; i < n; i++) {\n                if (p.charAt(i) == '*') {\n                    for (int j = 0; j < m; j++) {\n                        match[j+1] = match[j] || match[j+1]; \n                    }\n                } else {\n                    for (int j = m-1; j >= 0; j--) {\n                        match[j+1] = (p.charAt(i) == '?' || p.charAt(i) == s.charAt(j)) && match[j];\n                    }\n                    match[0] = false;\n                }\n            }\n            return match[m];\n        }\n    }
[]