Explanation:horse -> rorse (replace 'h' with 'r')
rorse -> rose (remove 'r')
rose -> ros (remove 'e')
The minimum edit distance between "horse" and "ros" is 3 (replace 'h' with 'r', remove 'r', remove 'e').
Example 2:
Input:word1 = "intention", word2 = "execution"
Output:5
Explanation:intention -> inention (remove 't')
inention -> enention (replace 'i' with 'e')
enention -> exention (replace 'n' with 'x')
exention -> exection (replace 'n' with 'c')
exection -> execution (insert 'u')
The minimum edit distance between "intention" and "execution" is 5.
Example 3:
Input:word1 = "", word2 = "abc"
Output:3
Explanation:The minimum edit distance between "" and "abc" is 3 (insert 'a', insert 'b', insert 'c').
Example 4:
Input:word1 = "abc", word2 = ""
Output:3
Explanation:The minimum edit distance between "abc" and "" is 3 (delete 'a', delete 'b', delete 'c').
Example 5:
Input:word1 = "abc", word2 = "abc"
Output:0
Explanation:The minimum edit distance between "abc" and "abc" is 0 (no operations needed).