标签:string src mamicode first tle 字符 mat etc title
class Solution { public: bool isMatch(string s, string p) { return isMatchCore(s.c_str(), p.c_str()); } bool isMatchCore(const char* s, const char* p) { if (*s == ‘\0‘ && *p == ‘\0‘) return true; if (*s != ‘\0‘ && *p == ‘\0‘) return false; bool first_match = *s && (*s == *p || *p == ‘.‘); if (*(p + 1) == ‘*‘) //下一位是* return isMatchCore(s, p + 2) //当前模式重复0次 || (first_match && isMatchCore(s + 1, p)); //当前字符重复 else return first_match && isMatchCore(s + 1, p + 1); } };
LeetCode 10. 正则表达式匹配 Regular Expression Matching
标签:string src mamicode first tle 字符 mat etc title
原文地址:https://www.cnblogs.com/ZSY-blog/p/12951308.html