Standard dp solution
int minDistance(string word1, string word2) {\n        int  m = word1.length(), n = word2.length();\n        if (m == 0) return n;\n        if (n == 0) return m
    int minDistance(string word1, string word2) {\n        int  m = word1.length(), n = word2.length();\n        if (m == 0) return n;\n        if (n == 0) return m;\n        \n        // table[i][j]: distance from words1.substr(0, i) to words2.substr(0, j) \n        int table[m+1][n+1];\n        for (int i = 0; i <= m; ++i) table[i][0] = i;\n        for (int j = 0; j <= n; ++j) table[0][j] = j;\n        // table[i][j] is the min distance between the next three values\n        // from table[i-1][j], table[i][j-1], or table[i-1][j-1] to table[i][j]\n        for (int i = 1; i <= m; ++i) {\n            for (int j = 1; j <= n; ++j) {\n                int cost = (word1[i-1] == word2[j-1] ? 0 : 1);\n                table[i][j] = min(min(table[i-1][j] + 1, table[i][j-1] + 1), table[i-1][j-1] + cost);\n            }\n        }\n        \n        return table[m][n];\n    }
[]