Minimum edit
InterviewTime limit2sMemory limit512 MB
Compute the Levenshtein distance between two lowercase strings, using the fewest insert, delete, and replace operations to change A into B.
- Level
Medium6 of 10
- Topics
- Dynamic programming, String, Array, Prefix sum
- Solved
- No attempts yet
Problem
Given two strings and , the task of turning into with the fewest operations is called the minimum edit problem.
Three operations apply to .
- Insert: put one character at any position of .
- Delete: remove one character of .
- Replace: change one character of into another character.
Given the two strings, write a program that computes the minimum number of edits.
Input
The first line has the string and the second line has the string . Both strings consist of lowercase letters only, and neither is longer than 1000 characters.
Output
Print on the first line the minimum number of edits that turn into .