Wildcard Matching

来源:互联网 发布:淘宝代销怎么发货图解 编辑:程序博客网 时间:2024/05/29 11:10
class Solution {public:    bool isMatch(const char *s, const char *p) {        const char *ss=s;        const char *star=NULL;                while(*s!='\0')        {            if(*s==*p||*s=='?'||*p=='?')            {                s++;                p++;            }            else               if(*p=='*')               {                   star=p++;                   ss=s;               }               else                  if(star)                  {                      p=star+1;                      s=++ss;                  }                  else                     return false;        }        while(*p=='*')            p++;        if(*p!='\0')           return false;        return true;    }};
word ladder 2写了好几个小时没写出来,
0 0
原创粉丝点击