Words Edit Distance
STRING
DYNAMIC PROGRAMMING
Problem
Given two strings word1
and word2
, return the minimum number of operations required to convert word1
into word2
. You are allowed to use the following operations:
- Insert a character
- Delete a character
- Replace a character
Examples
minDistance("kitten", "sitting") // returns 3 /* kitten -> sitten (replace "k" with "s"), sitten -> sittin (replace "e" with "i"), sittin -> sitting (insert "g" at the end). */
Loading...