DP Solution | Easy & Fast
\nclass Solution:\n    def minDistance(self, word1: str, word2: str) -> int:\n        #dp[i][j] will be the least distance from word1[:i] to word2[:j]\n        
```\nclass Solution:\n    def minDistance(self, word1: str, word2: str) -> int:\n        #dp[i][j] will be the least distance from word1[:i] to word2[:j]\n        dp = [[0 for _ in range(len(word2)+1)] for _ in range(len(word1)+1)]\n        for i in range(len(word1)+1):\n            dp[i][0] = i\n            for j in range(1,len(word2)+1):\n                if i == 0:\n                    dp[0][j] = j\n                elif word1[i-1] == word2[j-1]:\n                    dp[i][j] = dp[i-1][j-1]\n                else:\n                    dp[i][j] = min(dp[i-1][j-1],dp[i-1][j],dp[i][j-1])+1\n        return dp[-1][-1]  \n                                \n```
['Dynamic Programming', 'Python', 'Python3']