Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool isMatch(const string &s, const string &p) {
- int n=s.size(),m=p.size();
- dp[n][m]=true;
- for(int i=m-1;i>=0;i--){
- if(p[i]=='*') dp[n][i] = dp[n][i+1];
- }
- for(int i=n-1;i>=0;i--){
- for(int j=m-1;j>=0;j--){
- if((p[j]=='?' or ( p[j]==s[i]))) dp[i][j] = dp[i+1][j+1];
- if(p[j]=='*') dp[i][j] = dp[i+1][j] || dp[i][j+1];
- }
- }
- return dp[0][0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement