Skip to content

Files

Latest commit

3b3615c · Oct 9, 2022

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 9, 2022
Oct 9, 2022

Edit Distance

The edit distance between two strings is the minimum number of operations required to transform one string into the other.

The allowed operations are:

  • Add one character to the string.
  • Remove one character from the string.
  • Replace one character in the string.

For example, the edit distance between LOVE and MOVIE is 2, because you can first replace L with M, and then add I.

Your task is to calculate the edit distance between two strings.

Input:

The first argument of input contains a string, A.
The second argument of input contains a string, B.

Output:

Return an integer, representing the minimum number of steps required.

Constraints:

  • 1 <= length(A), length(B) <= 450

Example:

Input 1:
A = "abad"
B = "abac"

Output 1:
1

Explanation 1:
Operation 1: Replace d with c.