标签:style blog color io ar art div cti log
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
标签:style blog color io ar art div cti log
原文地址:http://www.cnblogs.com/cane/p/3934686.html