class Solution {
public:
bool isMatch(const char *s, const char *p) {
if(*p=='\0') return *s=='\0';
if(*p=='*')
{
while(*p=='*')
p++;
while(*s!='\0')
{
s++;
if(isMatch(s,p)) return true;
}
return isMatch(s,p);
}
else if(*s==*p||(*p=='?'&&*s!='\0'))
return isMatch(s+1,p+1);
else return false;
}
};
public:
bool isMatch(const char *s, const char *p) {
if(*p=='\0') return *s=='\0';
if(*p=='*')
{
while(*p=='*')
p++;
while(*s!='\0')
{
s++;
if(isMatch(s,p)) return true;
}
return isMatch(s,p);
}
else if(*s==*p||(*p=='?'&&*s!='\0'))
return isMatch(s+1,p+1);
else return false;
}
};