#K39777. Edit Distance Transformation

    ID: 26496 Type: Default 1000ms 256MiB

Edit Distance Transformation

Edit Distance Transformation

In this problem, you are given two strings ( A ) and ( B ). Your task is to compute the minimum number of operations required to transform string ( A ) into string ( B ). The allowed operations are:

  1. Insertion
  2. Deletion
  3. Substitution (Replacement)

The transformation cost is defined as the minimum number of these operations needed. This is essentially the edit distance problem.

For example, to transform "kitten" into "sitting": [ \text{edit_distance}(\texttt{kitten},\texttt{sitting}) = 3 ] because you can replace 'k' with 's', replace 'e' with 'i', and insert a 'g' at the end.

inputFormat

The input is read from standard input (stdin) and consists of exactly two lines:

  • The first line contains the string ( A ).
  • The second line contains the string ( B ).

Both strings contain only printable characters without spaces.

outputFormat

Output a single integer to standard output (stdout) indicating the minimum number of operations required to transform string ( A ) into string ( B ).## sample

kitten
sitting
3