Regular Expression Matching
2014-08-30 22:23
260 查看
递归法,遇到*符号时,尝试从零次到多次匹配。
参考:http://leetcode.com/2011/09/regular-expression-matching.html
代码:
动态规划法,有待补充。
参考:http://leetcode.com/2011/09/regular-expression-matching.html
代码:
class Solution { public: bool isMatch(const char *s, const char *p) { if(*p == '\0') return *s == '\0'; //next character is not * if(*(p+1) != '*') return (*s == *p || (*p == '.' && *s))&& isMatch(s+1, p+1); else { //next character is * while(*s == *p || (*p == '.' && *s)) { if(isMatch(s, p+2)) return true; s++; } return isMatch(s, p+2); } } };
动态规划法,有待补充。
相关文章推荐
- [LeetCode] Regular Expression Matching, Solution
- 【leetcode】第10题:Regular_Expression_Matching (Hard)
- LintCode_154 Regular Expression Matching
- 【10】Regular Expression Matching
- Leetcode 10 Regular Expression Matching
- 【LeetCode with Python】 Regular Expression Matching
- 46:Regular Expression Matching
- 【LeetCode】10. Regular Expression Matching
- LeetCode 10. Regular Expression Matching
- leetcode---regular-expression-matching---字符串
- LeetCode: Regular Expression Matching
- leetcode 10. Regular Expression Matching
- leetcode Regular Expression Matching
- [LeetCode]Regular Expression Matching、Wildcard Matching
- Regular Expression Matching
- Regular Expression Matching
- [leetcode 10] Regular Expression Matching
- 【leetcode刷题笔记】Regular Expression Matching
- LeetCode-Regular Expression Matching-正则匹配-DP
- Regular Expression Matching in the Wild(中文)