Problem Description
You are given two strings, A and B of same length.
In one operation you can set some A[x] equal to B[x], this cost 1 coin.
You can also Reverse a substring A[i...j] atmost once. this cost C coins.
Find minimum operation required to make both string equal.
Answers
Answer:
here is your answer
Explanation:
You are given two strings, A and B of same length.
In one operation you can set some A[x] equal to B[x], this cost 1 coin.
You can also Reverse a substring A[i...j] atmost once. this cost C coins.
Find minimum operation required to make both string equal.
Problem Constraints
1 <= |A| = |B| <= 1000
A and B consist of lower case alphabets
0 <= C <= |A|
Input Format
First argument of input contains a string A.
Second argument of input contains a string B.
Third argument of input contains an integer C.
Output Format
Return an integer denoting minimum coins to make strings equal.
Example Input
Input 1:
A = "abceda", B = "bdec of", C = 1
Input 2:
A = "finger", B = "ginger", C = 0
Example Output
Output 1:
3
Output 2:
1
Example Explanation
Explanation 1:
Initially we have, A = "abceda"
set A[0] = B[0], A = "bbceda"
set A[5] = B[5], A = "bbcedo"
reverse (1,4), A = "bdecbo"
Explanation 2:
set A[0] = B[0]