Fastest python code with straightforward visual explanation.
\n\n              +r      +o       +s\n        horse   rhorse  rohorse roshorse\n    -h       \u2198\uFE0F 1\n        orse    rorse   roorse  rosorse\n    -o   
\n\n              +r      +o       +s\n        horse   rhorse  rohorse roshorse\n    -h       \u2198\uFE0F 1\n        orse    rorse   roorse  rosorse\n    -o               \u2198\uFE0F 0\n        rse     rrse    rorse   rosrse\n    -r                   \u2B07\uFE0F 1   \n        se      rse     rose    rosse\n    -s                       \u2198\uFE0F 0\n        e       re      roe     rose\n    -e                           \u2B07\uFE0F 1\n        ""      r       ro      ros\n\n\n- \u27A1\uFE0Frightward is insertion\n- \u2B07\uFE0Fdownward is deletion\n- \u2198\uFE0Fdiagonal is replacement\n\nTry to go diagonally as much as possible!\n\n\n# Code\n```\nfrom typing import List, Optional\n\n# 72. Edit Distance\nclass Solution:\n    def minDistance(self, word1: str, word2: str) -> int:\n\n        row, col = len(word1), len(word2)\n\n        d = [[0] * (col+1) for _ in range(row+1)]\n\n        for i in range(row+1):\n            d[i][0] = i\n        for j in range(col+1):\n            d[0][j] = j\n\n        for i in range(1, row+1):\n            for j in range(1, col+1):\n                \n                \n\n                d[i][j] = min(\n                    d[i-1][j-1] + (0 if word1[i-1] == word2[j-1] else 1), # replacement\n                    d[i][j-1] + 1, # insertion\n                    d[i-1][j] + 1 # deletion\n                )\n        \n        return d[-1][-1]\n```
['Python3']