Linear runtime and constant space solution
I found this solution from http://yucoding.blogspot.com/2013/02/leetcode-question-123-wildcard-matching.html\n\n\n----------\n\n\nThe basic idea is to have one 
I found this solution from http://yucoding.blogspot.com/2013/02/leetcode-question-123-wildcard-matching.html\n\n\n----------\n\n\nThe basic idea is to have one pointer for the string and one pointer for the pattern.  This algorithm iterates at most length(string) + length(pattern) times, for each iteration, at least one pointer advance one step. \n\n\n----------\n\nHere is Yu's elegant solution in C++\n\n     bool isMatch(const char *s, const char *p) {\n            const char* star=NULL;\n            const char* ss=s;\n            while (*s){\n                //advancing both pointers when (both characters match) or ('?' found in pattern)\n                //note that *p will not advance beyond its length \n                if ((*p=='?')||(*p==*s)){s++;p++;continue;} \n\n                // * found in pattern, track index of *, only advancing pattern pointer \n                if (*p=='*'){star=p++; ss=s;continue;} \n\n                //current characters didn't match, last pattern pointer was *, current pattern pointer is not *\n                //only advancing pattern pointer\n                if (star){ p = star+1; s=++ss;continue;} \n\n               //current pattern pointer is not star, last patter pointer was not *\n               //characters do not match\n                return false;\n            }\n \n           //check for remaining characters in pattern\n            while (*p=='*'){p++;}\n\n            return !*p;  \n        }\n\n\n----------\n\n\nHere is my re-write in Java\n\n    \ufeff\ufeff\ufeffboolean comparison(String str, String pattern) {\n            int s = 0, p = 0, match = 0, starIdx = -1;            \n            while (s < str.length()){\n                // advancing both pointers\n                if (p < pattern.length()  && (pattern.charAt(p) == '?' || str.charAt(s) == pattern.charAt(p))){\n                    s++;\n                    p++;\n                }\n                // * found, only advancing pattern pointer\n                else if (p < pattern.length() && pattern.charAt(p) == '*'){\n                    starIdx = p;\n                    match = s;\n                    p++;\n                }\n               // last pattern pointer was *, advancing string pointer\n                else if (starIdx != -1){\n                    p = starIdx + 1;\n                    match++;\n                    s = match;\n                }\n               //current pattern pointer is not star, last patter pointer was not *\n              //characters do not match\n                else return false;\n            }\n            \n            //check for remaining characters in pattern\n            while (p < pattern.length() && pattern.charAt(p) == '*')\n                p++;\n            \n            return p == pattern.length();\n    }
[]