Simple C++ | Memoization
\n\n# Code\n\nclass Solution {\npublic:\n\n    bool solve(string &s,string &p,int i,int j,vector<vector<int>> &dp){\n\n        if(i<0 && j<0){\n            retu
\n\n# Code\n```\nclass Solution {\npublic:\n\n    bool solve(string &s,string &p,int i,int j,vector<vector<int>> &dp){\n\n        if(i<0 && j<0){\n            return 1;\n        }\n\n        if(i>=0  && j<0) return 0;\n     \n        \n        if(i<0 && j>=0) {\n            while(j>=0) {\n                if(p[j]!=\'*\') return 0;\n                j--;\n            }\n            return 1;\n        };\n        if(dp[i][j]!=-1) return dp[i][j];\n        if(p[j]==s[i] || p[j]==\'?\'){\n           return dp[i][j]=solve(s,p,i-1,j-1,dp);\n\n        }\n\n\n\n        if(p[j]==\'*\'){\n            int t=solve(s,p,i-1,j,dp);\n            \n            int neglect=solve(s,p,i,j-1,dp);\n            return dp[i][j]=t||neglect;\n        }\n        return dp[i][j]=0;\n    }\n    bool isMatch(string &s, string &p) {\n     \n        int n=s.size();\n        int m=p.size();\n       \n\n        vector<vector<int>> dp(n,vector<int>(m,-1));\n       \n        return solve(s,p,n-1,m-1,dp);\n    }\n};\n```
['C++']