Regular Expression Matching
来源:互联网 发布:温州动车事故真相知乎 编辑:程序博客网 时间:2024/06/08 05:51
首先明确一点s中是没有 * 和 . 的,只有正常字符,很久才弄清楚这一点,不然这题很难理解
//s 待匹配字符串,只有普通的字符,没有*, .
//p 匹配模板
bool isMatch(const char *s, const char *p) {
- if (*p == '\0') return *s == '\0';
- // next char is not '*': must match current character
- if (*(p+1) != '*')
- return ((*p == *s) || (*p == '.' && *s != '\0')) && isMatch(s+1, p+1);
- // next char is '*'
- while ((*p == *s) || (*p == '.' && *s != '\0')) {
- if (isMatch(s, p+2)) return true;
- s++;
- }
- return isMatch(s, p+2);
}
0 0
- LeetCode: Regular Expression Matching
- LeetCode: Regular Expression Matching
- leetcode Regular Expression Matching
- [Leetcode] Regular Expression Matching
- Regular Expression Matching
- Regular Expression Matching
- [LeetCode]Regular Expression Matching
- Regular Expression Matching
- LeetCode-Regular Expression Matching
- Regular Expression Matching
- Regular Expression Matching LeetCode
- Regular Expression Matching
- LeetCode | Regular Expression Matching
- LeetCode: Regular Expression Matching
- Leetcode: Regular Expression Matching
- [LeetCode] Regular Expression matching
- [LeetCode] Regular Expression Matching
- LeetCode Regular Expression Matching
- 第二章(线性表之顺序存储)
- Luci实现框架
- [LeetCode]Copy List with Random Pointer &Clone Graph 复杂链表的复制&图的复制
- 个性化控件(View)篇
- FragmentPagerAdapter.notifyDataSetChanged() 并不能更新其 Fragment?
- Regular Expression Matching
- (windows编程 学习笔记二) 结构化异常处理(异常处理程序和软件异常)
- 优秀项目篇
- RGB十六位色转换
- 发发小感叹
- CKEDITOR富文本编辑器+AJAX+JQUERY+ListView综合应用
- 数据挖掘之预测
- python-subprocess创建附加进程
- 开发及测试工具篇