Recursion and Memoization - Aditya Verma Approach
Do upvote, if found helpful.\n\nRecursive - \n\n\nclass Solution {\npublic:\n\n    int fun(string a, string b, int i, int j)\n    {\n        if(i<0)\n        re
Do upvote, if found helpful.\n\nRecursive - \n\n```\nclass Solution {\npublic:\n\n    int fun(string a, string b, int i, int j)\n    {\n        if(i<0)\n        return j+1; \n\n        if(j<0)\n        return i+1;\n\n        if(a[i]==b[j])\n        return fun(a,b,i-1,j-1);\n\n        else\n        return 1 + min(fun(a,b,i-1,j), min(fun(a,b,i,j-1),fun(a,b,i-1,j-1))); \n    }\n\n    \n    int minDistance(string a, string b) \n    {\n        int n = a.size();\n        int m = b.size();\n\n        return fun(a,b,n-1,m-1);   \n    }\n};\n```\n\nMemoization - \n\n```\nclass Solution {\npublic:\n    \n    vector<vector<int>> dp;\n\n    int fun(string a, string b, int i, int j)\n    {\n        if(i<0)\n        return j+1; \n\n        if(j<0)\n        return i+1;\n\n        if(dp[i][j]!=-1)\n        return dp[i][j];\n\n        if(a[i]==b[j])\n        return dp[i][j] = fun(a,b,i-1,j-1);\n\n        else\n        return dp[i][j] = 1 + min(fun(a,b,i-1,j), min(fun(a,b,i,j-1),fun(a,b,i-1,j-1))); \n    }\n\n    \n    int minDistance(string a, string b) \n    {\n        int n = a.size();\n        int m = b.size();\n\n        dp.clear();\n        dp.resize(n+1,vector<int> (m+1,-1));\n        return fun(a,b,n-1,m-1);   \n    }\n};\n```
['Recursion', 'Memoization', 'C++']