Edit Distance
HardDynamic Programming
Decode it first. Clues, constraints, pattern and plan before any code.Return the minimum number of single-character edits needed to turn string a into string b. An edit is one of: insert a character, delete a character, or replace a character.
a = "horse", b = "ros" → 3 (horse → rorse → rose → ros)
a = "kitten", b = "sitting" → 3
a = "", b = "abc" → 3 (insert all three)Constraints
0 <= a.length, b.length <= 500- Both strings contain only lowercase letters.