[[ SWIFT ]] ((85% Beat)) Using Dynamic Programming Solution - O(N * M) Quadratic Speed - EaZy BrEeZy
\nclass Solution {\n    func minDistance(_ word1: String, _ word2: String) -> Int {\n        \n        if word1.count == 0 { return word2.count }\n        if wo
```\nclass Solution {\n    func minDistance(_ word1: String, _ word2: String) -> Int {\n        \n        if word1.count == 0 { return word2.count }\n        if word2.count == 0 { return word1.count }\n        \n        var grid = [[Int]](repeating: [Int](repeating: 0, count: word2.count + 1), count: word1.count + 1)\n        \n        for x in 0...word1.count { grid[x][0] = x }\n        for y in 0...word2.count { grid[0][y] = y }\n        \n        var word1 = Array(word1)\n        var word2 = Array(word2)\n        \n        for x in 1...word1.count {\n            for y in 1...word2.count {\n                if word1[x - 1] == word2[y - 1] {\n                    grid[x][y] = grid[x-1][y-1]\n                } else {   \n                    grid[x][y] = min(grid[x-1][y], min(grid[x-1][y-1], grid[x][y-1])) + 1\n                }       \n            }\n        }\n        return grid[word1.count][word2.count]\n    }\n}\n```\n\nBoom, you\'re on the payroll now. Winner winner, chicken dinner. I guess that\'s why they call it the blues.
[]