Given two strings word1 and word2, return the minimum number of operations required to convert word1 into word2. The allowed operations are insertion, deletion, and substitution. Pattern focus: Edit distance. This is the standard Levenshtein DP formulation.
word1 = source string, word2 = target string
minimum number of edit operations
Example 1:
Input:
word1 = "horse" word2 = "ros"
Output:
3
Explanation:
horse -> rorse -> rose -> ros.
Example 2:
Input:
word1 = "intention" word2 = "execution"
Output:
5
Explanation:
This is the classic edit-distance example.