You are given two strings a and b. In one edit you may:
Compute the minimum number of edits required to transform a into b. This value is symmetric and is uniquely determined by the two strings.
Line 1: the string a.
Line 2: the string b.
Either string may be empty (an empty line). Strings consist of printable characters with no leading or trailing spaces and contain no spaces internally.
A single integer: the minimum number of insert/delete/substitute edits to transform a into b.
a ≤ 2000b ≤ 2000Classic three edits
Input
kitten sitting
Expected
3
Explanation
Substitute k->s, substitute e->i, and insert g at the end: three edits turn 'kitten' into 'sitting'.
Longer pair
Input
sunday saturday
Expected
3
Explanation
Insert 'a' and 't' and substitute 'n'->'r' (with the rest aligning), giving a minimum of 3 edits.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →