## Solution ## Problem ### Problem Statement Given two strings $\texttt{word1}$ and $\texttt{word2}$, return the minimum number of operations required to convert $\texttt{word1}$ to $\texttt{word2}$. You have the following three operations permitted on a word: - Insert a character - Delete a character - Replace a character ### Example 1 **Input:** $\texttt{word1} = \text{"horse"}$, $\texttt{word2} = \text{"ros"}$ **Output:** 3 **Explanation:** horse $\to$ rorse (replace 'h' with 'r') rorse $\to$ rose (remove 'r') rose $\to$ ros (remove 'e') ### Example 2 **Input:** $\texttt{word1} = \text{"intention"}$, $\texttt{word2} = \text{"execution"}$ **Output:** 5 **Explanation:** intention $\to$ inention (remove 't') inention $\to$ enention (replace 'i' with 'e') enention $\to$ exention (replace 'n' with 'x') exention $\to$ exection (replace 'n' with 'c') exection $\to$ execution (insert 'u') ### Constraints $0 \leq \texttt{word1.length}, \texttt{word2.length} \leq 500$ $\texttt{word1}$ and $\texttt{word2}$ consist of lowercase English letters.