medium
Edit Distance
Given two words, return the minimum number of single-character insertions, deletions or substitutions required to transform the first into the second.
Constraints
- 0 ≤ word1.length, word2.length ≤ 500
- Lowercase English letters
Examples
in: word1 = "horse", word2 = "ros"
out: 3
horse → rorse → rose → ros.
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.