首页 > 其他 > 详细

LeetCode – Refresh – Regular Expression Matching

时间:2015-03-22 16:27:50      阅读:218      评论:0      收藏:0      [点我收藏+]

Do not confused with check if (*p == ‘\0‘) return *s == ‘\0‘;

p is the format that used to match. If p is already reaching end, s still has some chars left, they can not match.

 1 class Solution {
 2 public:
 3     bool isMatch(const char *s, const char *p) {
 4         if (*p == \0) return *s == \0;
 5         if (*(p+1) != *) return (*s == *p || *s != \0 && *p == .) && isMatch(s+1, p+1);
 6         while (*s == *p || *s != \0 && *p == .) {
 7             if (isMatch(s, p+2)) return true;
 8             s++;
 9         }
10         return isMatch(s, p+2);
11     }
12 };

 

LeetCode – Refresh – Regular Expression Matching

原文:http://www.cnblogs.com/shuashuashua/p/4357452.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!