[leetCode] Regular Expression Matching
来源:互联网 发布:获取端口号 编辑:程序博客网 时间:2024/05/29 08:16
Implement regular expression matching with support for '.'
and '*'
.
'.' Matches any single character.'*' Matches zero or more of the preceding element.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") → falseisMatch("aa","aa") → trueisMatch("aaa","aa") → falseisMatch("aa", "a*") → trueisMatch("aa", ".*") → trueisMatch("ab", ".*") → trueisMatch("aab", "c*a*b") → true
class Solution {public: bool isMatch(const char *s, const char *p) { if(s == NULL || p == NULL) return false; if(*p == '\0') return *s == '\0'; if(*(p + 1) == '*'){ while(*s != '\0' && (*p == *s || *p == '.')){ if(isMatch(s, p + 2)) return true; s ++; } return isMatch(s, p + 2); }else{ if(*s != '\0' && (*p == *s || *p == '.')) return isMatch(s + 1,p + 1); else return false; } }};
0 0
- LeetCode: Regular Expression Matching
- LeetCode: Regular Expression Matching
- leetcode Regular Expression Matching
- [Leetcode] Regular Expression Matching
- [LeetCode]Regular Expression Matching
- LeetCode-Regular Expression Matching
- Regular Expression Matching LeetCode
- 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
- leetcode: Regular Expression Matching
- LeetCode Regular Expression Matching
- Leetcode: Regular Expression Matching
- leetcode:Regular Expression Matching
- C语言练习-指针(数组,字符串)
- 博客搬家通知!!!
- C 语言程序设计实践 4.3 龟兔赛跑
- iOS开发 delegate,SEL和Block
- Android使用Asynchronous Http Client完成登录保存cookie的问题
- [leetCode] Regular Expression Matching
- 【LeetCode】Merge Two Sorted Lists
- Visual Studio 2013 C/C++单元测试
- 学生管理系统源代码
- C 语言程序设计实践 4.4 车牌号
- ios开发——用UITableView展示多行多列图片
- 分布式爬虫系统
- C 语言程序设计实践 4.5 四边形
- 系统定时任务 crontab