Description
Solutions
String Operation

You are given two strings A and B consisting of lowercase latin letters, i.e. {a, b, c, ..., z}.

You can perform any number of operations (possibly zero) on A and B and in one operation you can:

  • Remove the first character from A or B
  • Remove the last character from A or B
  • Find the minimum number of operations that you have to perform to make A equal to B.

    Note:

  • It is possible that A or B becomes empty while performing operations.
  • It is given that two empty strings are equal.
  • Input format

    The first line contains a string, A, denoting the given string.

    The next line contains a string, B, denoting the given string.

    Constraints

    1 <= len(A) <= 100

    1 <= len(B) <= 100

    Example 1:

    Input:  A = "abaca", B = "ababa"
    Output: 4
    Explanation:

    Here, A = "abaca", B = "ababa"

    We can remove two characters from both of the strings so that they become equal.

    Hence, the operations performed is equal to 2.

    Example 2:

    Input:  A = "abcee", B = "efgee"
    Output: 6
    Explanation:

    Here, A = "abcee", B = "efgee"

    We can remove the first 3 characters from both strings A and B, so that they both become equal to "ee".

    Hence, the operations performed is equal to 6.

    Example 3:

    Input:  A = "i jhk", B = "ou jpopp"
    Output: 9
    Explanation:

    Here, A = "i jhk", B = "ou jpopp"

    It can be found that the minimum number of operations required to make A and B equal are 9.

    Constraints:
      See above
    Thumbnail 0
    Testcase

    Result
    Case 1

    input:

    output: