Edit Distance
Return the fewest single-character insertions, deletions and replacements needed to transform word1 into word2.
Example 1
word1 = "horse"
word2 = "ros"3Explanation
horse->rorse replaces h, then delete the extra r to get rose and delete e to get ros: three edits.
Example 2
word1 = ""
word2 = "abc"3Explanation
Insert a,b,c into the empty string for three edits.
Example 3
word1 = "same"
word2 = "same"0Explanation
Identical strings need no edit.
Constraints
- 0 <= string lengths <= 500
- Strings contain lowercase English letters
Function contract
minDistanceArguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
"horse""ros"