C++ Recursive, memoization and Dp
Recursive:\n\nint editDistance(string s, string t)\n{\n    if (s.size() == 0 || t.size() == 0)\n        return max(s.size(), t.size());\n    if (s[0] == t[0])\n
**Recursive:**\n```\nint editDistance(string s, string t)\n{\n    if (s.size() == 0 || t.size() == 0)\n        return max(s.size(), t.size());\n    if (s[0] == t[0])\n        return editDistance(s.substr(1), t.substr(1));\n    else\n    {\n        // insert\n        int a = 1 + editDistance(s.substr(1), t);\n        // delete\n        int b = 1 + editDistance(s, t.substr(1));\n        // replace\n        int c = 1 + editDistance(s.substr(1), t.substr(1));\n        return min(a, min(b, c));\n    }\n}\n\nint minDistance(string s, string t) {\n\treturn editDistance(s,t)\n}\n```\n\n**Memoization:**\n```\nint editDistance2(string s, string t, vector<vector<int>> ans)\n{\n    int m = s.size();\n    int n = t.size();\n    if (s.size() == 0 || t.size() == 0)\n        return max(s.size(), t.size());\n    if (ans[m][n] != -1)\n        return ans[m][n];\n    if (s[0] == t[0])\n    {\n        ans[m][n] = editDistance2(s.substr(1), t.substr(1), ans);\n        return ans[m][n];\n    }\n    else\n    {\n        // insert\n        int a = 1 + editDistance2(s.substr(1), t, ans);\n        // delete\n        int b = 1 + editDistance2(s, t.substr(1), ans);\n        // replace\n        int c = 1 + editDistance2(s.substr(1), t.substr(1), ans);\n        ans[m][n] = min(a, min(b, c));\n        return ans[m][n];\n    }\n}\nint minDistance(string s, string t) {\n    vector<vector<int>> ans(s.size() + 1, vector<int>(t.size() + 1, -1));\n\treturn editDistance2(s,t)\n}\n```\n\n**DP:**\n```\nint minDistance(string s, string t) {\n        int m = s.size();\n    int n = t.size();\n\n    int **ans = new int *[m + 1];\n    for (int i = 0; i <= m; i++)\n    {\n        ans[i] = new int[n + 1];\n    }\n\n    // Fill the 0th row with 0\n    for (int j = 0; j <= n; j++)\n    {\n        ans[0][j] = j;\n    }\n    // Fill the 0th row with 0\n    for (int i = 0; i <= m; i++)\n    {\n        ans[i][0] = i;\n    }\n    // Fill the remaining row with shortest Distances\n    for (int i = 1; i <= m; i++)\n    {\n        for (int j = 1; j <= n; j++)\n        {\n            if (s[m - i] == t[n - j])\n                ans[i][j] = ans[i - 1][j - 1];\n            else\n            {\n                int a = 1 + ans[i - 1][j];\n                int b = 1 + ans[i][j - 1];\n                int c = 1 + ans[i - 1][j - 1];\n                ans[i][j] = min(a, min(b, c));\n            }\n        }\n    }\n    return ans[m][n];\n    }\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'C']