[C++] dp
Case 1 :\nIf first string is empty, only option is to insert all characters of second string\nCase 2 :\nIf second string is empty, only option is to remove all 
**Case 1 :**\nIf first string is empty, only option is to insert all characters of second string\n**Case 2 :**\nIf second string is empty, only option is to remove all characters of second string\n**Options :**\n* dp [i-1][j - 1] -> If we replace the character.\n* dp [i][j - 1] -> If we delete the character.\n* dp [i - 1][j] -> If we insert the character.\n```\nclass Solution {\npublic:\n    int minDistance(string word1, string word2) {\n        int m = word1.length();\n        int n = word2.length();\n        vector<vector<int>> dp(n + 1, vector<int> (m + 1, 0));\n\t\t\n        for(int i = 1; i <= n; i++){ \n            dp[i][0] = 1 + dp[i - 1][0];\n        }\n        for(int i = 1; i <= m; i++){\n            dp[0][i] = 1 + dp[0][i - 1];\n        }\n        \n        for(int i = 1; i <= n; i++){\n            for(int j = 1; j <= m; j++){\n              \n                if(word2[i - 1] == word1[j - 1]){\n                    dp[i][j] = dp[i - 1][j - 1];\n                }\n                else{\n                    dp[i][j] = 1 + min({dp[i - 1][j - 1], dp[i][j - 1], dp[i - 1][j]});\n                }\n               \n            } \n        }\n        return dp[n][m];\n    }\n};\n```
[]