9. Edit Distance
HardDynamic ProgrammingString
Print the minimum number of single-character insertions, deletions or replacements needed to turn word1 into word2.
Input format
Line 1: word1 Line 2: word2 (either may be empty)
Output format
The edit distance.
Example 1
Input
horse ros
Output
3
Example 2
Input
intention execution
Output
5
Constraints
0 ≤ length ≤ 500
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…