Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool isMatch(const string &s,const string &p, int i=0, int j=0) {
- int n=s.size(),m=p.size();
- string s_sub = (i<n)?s.substr(i):"",p_sub =(j<m)?p.substr(j):"";
- if(p_sub.empty()) return s_sub.empty();
- if(j<m and (p[j]=='?' or (i<n and p[j]==s[i] )))
- return isMatch(p,s,i+1,j+1);
- if (j<m and p[j] == '*')
- return (isMatch(s,p,i+1,j) || isMatch(s,p,i,j+1));
- return false;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement