Wildcard Matching
来源:互联网 发布:吉列剃须刀哪款好 知乎 编辑:程序博客网 时间:2024/05/21 21:42
时间复杂度O(mn),当碰到*通配符时,记录当前的s和p的位置,并从s继续向后匹配,若中间匹配失败,则尝试讲s+1,然后与p匹配。
class Solution {public: bool isMatch(const char *s, const char *p) { const char *ss = 0, *pp = 0; while(*s) { if(*s == *p || *p == '?') s++, p++; else if(*p == '*') { while(*p == '*') p++; if(*p == 0) return true; ss = s; pp = p; } else if(ss) { s = ++ss; p = pp; } else return false; } while(*p == '*') p++; return *p == 0 && *s == 0; }};
0 0
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Ogre 学习记录
- Delphi版本号对照
- aucad1012_64位安装前必须安装的程序
- UVA 11080 - Place the Guards(二分图判定)
- nyoj 93 汉诺塔(三)
- Wildcard Matching
- priority queue 优先队列
- debian上eAccelerator 的安装
- const char * 的终结贴(看完无需其他任何文章,从此不再蛋疼)
- 花生壳安全吗
- eclipse出现workspace in use or cannot be created
- 编程异常——如果你报createSQLQuery is not valid without active transaction,...
- 【度学堂】百度QA的特点与核心价值
- 图片的上传