Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Solution {
public:
bool isMatch(string s, string p) {
if(p.empty()) return s.empty();
bool myFirst = !s.empty() && (s[0] == p[0] || p[0] == '.');
if(p.size()>=2 && p[1] == '*')
{
return myFirst&&isMatch(s.substr(1),p)||isMatch(s, p.substr(2));
}
else
{
return myFirst&&isMatch(s.substr(1),p.substr(1));
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment