首页 > 其他 > 详细

LeetCode--Regular Expression Matching

时间:2014-08-25 13:16:14      阅读:160      评论:0      收藏:0      [点我收藏+]
 1 class Solution {
 2 public:
 3     bool isMatch(const char *s, const char *p) {
 4         // Start typing your C/C++ solution below
 5         // DO NOT write int main() function
 6         if (*p == \0) {
 7             return *s == \0;
 8         }
 9         
10         if (*(p + 1) == *) {
11             while (*s != \0 && (*s == *p || *p == .)) {
12                 if (isMatch(s, p + 2)) {
13                     return true;
14                 }
15                 s++;                
16             }
17                return isMatch(s, p + 2);
18         }
19         else {
20             if (*s != \0 && (*s == *p || *p == .)) {
21                 return isMatch(s + 1, p + 1);
22             }
23         }
24         
25         return false;
26     }
27 };

LeetCode--Regular Expression Matching

原文:http://www.cnblogs.com/cane/p/3934686.html

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