Problem Statement: String Transformation

You are given two strings $s1$ and $s2$. Your task is to determine the minimum number of operations required to transform $s1$ into $s2$. You can use the following three operations:

  1. Insert a character into the string.
  2. Delete a character from the string.
  3. Substitute one character in the string with another character.

Each operation has a cost of 1 unit, and your goal is to achieve the transformation with the minimum cost possible.

Input

Output

Example

Input: s1 = "kitten", s2 = "sitting"
Output: 3

Explanation

- kitten -> sitten (substitute 'k' with 's')
- sitten -> sittin (substitute 'e' with 'i')
- sittin -> sitting (insert 'g')

Objective

Implement an efficient algorithm to calculate the minimum number of operations needed to convert $s1$ into $s2$ and return the cost.

Submission

Think you’ve cracked it? Submit your solutions here and wait a few days to get it verified.

Note

Solution

The solution to the problem can be found at Solution 1.