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 };