Edit distance
The fewest 1-letter changes (insert, delete or replace) needed to turn one text into another. It measures how similar they are.
Example
From «kitten» to «sitting» there are 3 changes: k to s, e to i, and adding a g at the end.
Test yourself: Edit distance
Edit distance
From «kitten» to «sitting» the edit distance is ___.
k to s, e to i, and adding a g at the end: 2 replacements and 1 insertion.
Edit distance
dp[i, j] is the fewest changes to turn the first i letters of s into the first ___ of t.
With s = «kitten» and t = «sitting», dp[6, 7] = 3 is the full answer.
Edit distance
If s[i − 1] and t[j − 1] match, dp[i, j] = dp[i − 1, ___].
Both letters are skipped: in «cat» and «bat», the last 2 match and dp[3, 3] = dp[1, 1] = 1.
0/3
â–¶ Play