72. Edit Distance
Practice Edit Distance for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
One operation inserts a character, deletes a character, or replaces one character with another. Return the fewest operations that turn word1 into word2.
Example
word1 = "horse", word2 = "ros" -> 3
(horse -> rorse -> rose -> ros)
word1 = "intention", word2 = "execution" -> 5
Constraints
- 0 <= word1.length, word2.length <= 500
- Both strings are lowercase English letters