### Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.

'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).

The matching should cover the entire input string (not partial).

The function prototype should be:
bool isMatch(const char *s, const char *p)

Some examples:
isMatch("aa","a") → false
isMatch("aa","aa") → true
isMatch("aaa","aa") → false
isMatch("aa", "*") → true
isMatch("aa", "a*") → true
isMatch("ab", "?*") → true
isMatch("aab", "c*a*b") → false
class Solution {
public:

/*
//递归解法，会TLE。
bool isMatch(string s, string p) {

int sLen=s.size();
int pLen=p.size();
// if (pLen > 30000) return false; // the trick
if(pLen==0)
return sLen==0;

if(p[0]=='*')
{
while(p[0]=='*')
p=p.substr(1);
while(sLen>0)
{
if(isMatch(s,p))
return true;
sLen--;
s=s.substr(1);
}
return isMatch(s,p);
}
else if(p[0]==s[0] || (sLen>0 && p[0]=='?'))
return isMatch(s.substr(1),p.substr(1));

return false;
}
*/

bool isMatch(string s, string p) {
int sLen=s.size();
int pLen=p.size();

int i=0,j=0,pi=0,pj=pLen;

while(i<sLen)
{
if(s[i]==p[j]||p[j]=='?')
{
i++;
j++;
continue;
}

if(p[j]=='*'){
pj=j++;
pi=i;
continue;
}

if(pj<pLen){
j=pj+1;//j是*后面的字符，i从pi开始逐个匹配
i=++pi;
continue;
}
return false;
}
while(p[j]=='*'){
j++;
}
return j==pLen;
}
};

#### LeetCode 44. Wildcard Matching（模糊匹配）

2016-05-21 04:07:39

#### [leetcode] Wildcard Matching 通配符匹配

2016-05-02 16:21:55

#### 通配符匹配 & 正则表达式匹配【leetcode Wildcard Matching & Regular Expression Matching】

2013-08-30 12:02:07

#### 异常 2 problemscvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be foun

2016-05-01 16:35:40

#### Eclipse XML报错 cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be fou

2017-06-29 01:43:13

#### LeetCode-- Wildcard Matching

2017-08-09 11:28:51

#### Dubbo cvc-complex-type.2.4.c 错误，dubbo.xsd

2016-12-01 22:20:25

#### LeetCode --- 44. Wildcard Matching

2015-02-10 08:58:41

#### cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration

2016-11-03 16:36:25

#### 关于dubbo创建服务和引用服务时，会报错：cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration...

2017-09-02 15:35:11

## 不良信息举报

Wildcard Matching 字符串含？，*匹配