memoization to tabulation
\n# Memoization:-\n\nclass Solution {\npublic:\n    \n    \n    int helper(int i,int j,string s,string p,vector>& dp){\n         \n         if(i==0 && j==0 )   
\n# **Memoization:-**\n\nclass Solution {\npublic:\n    \n    \n    int helper(int i,int j,string s,string p,vector<vector<int>>& dp){\n         \n         if(i==0 && j==0 )    return true;\n         \n         if(i==0 || j==0 )    {\n            \n            if(i==0 && p[j-1]==\'*\') return helper(i,j-1,s,p,dp);  \n            else                    return false;\n             \n         }\n        \n        if(dp[i][j]!=-1) return dp[i][j];\n  \n        if(p[j-1]==\'*\' || p[j-1]==\'?\' ){\n            \n         if(p[j-1]==\'?\') return dp[i][j]=helper(i-1,j-1,s,p,dp);\n         else            return dp[i][j]=(helper(i-1,j,s,p,dp) || helper(i-1,j-1,s,p,dp) || helper(i,j-1,s,p,dp));\n            \n        }\n        else {\n            if(s[i-1]==p[j-1]) return dp[i][j]=helper(i-1,j-1,s,p,dp);\n            else               return false;    \n        }\n    }\n\t\n    bool isMatch(string s, string p) {\n    \n        int n1=s.size();\n        int n2=p.size();\n        \n        vector<vector<int>> dp(n1+1,vector<int> (n2+1,-1));\n        return helper(s.size(),p.size(),s,p,dp);\n    }\n};\n\nSaldy it didn\'t work so i need to convert it to tabulator form\n\n# **Tabulation:-**\n\nclass Solution {\npublic:\n        \n    bool isMatch(string s, string p) {\n    \n        int n1=s.size();\n        int n2=p.size();\n        \n        vector<vector<bool>> dp(n1+1,vector<bool> (n2+1,false));\n        \n        for(int i=0;i<=n1;++i){\n            \n            for(int j=0;j<=n2;++j){\n                \n                if(i==0 && j==0) dp[i][j]=true;\n                else if (i==0 || j==0){\n                    \n\t\t\t\t\t if(i==0 && p[j-1]==\'*\') dp[i][j]=dp[i][j-1];  \n\t\t\t\t\t else                    dp[i][j]=false;  \n\t\t\t\t\t \n                }\n               else if(p[j-1]==\'*\' || p[j-1]==\'?\' ){\n\t\t\t   \n                 if (p[j-1]==\'?\') dp[i][j]=dp[i-1][j-1];\n                 else             dp[i][j]=dp[i-1][j] + dp[i-1][j-1] + dp[i][j-1];\n              \n\t\t\t  }\n            else{\n                if(s[i-1]==p[j-1]) dp[i][j]=dp[i-1][j-1];\n                else               dp[i][j]=false;  \n              }    \n           }           \n        }\n        return dp[n1][n2];  \n    }\n};\n\n\n\n\n
[]