You are given two strings A and B. You need to merge these strings, considering all characters that are both prefix of A and suffix of B once.
For example: A = "abcde", B = "cdefg", merged string = "abcdefg".
Before merging, any one of the following operations can be performed at max once:
Print the minimum length possible for the merged string.
Constraints:
1 <= T <= 1000 (no of test cases)
1 <= |A|, |B| <= 10^4
Examples:
2 (no of test cases)
ababc
bcabc
cdefg
abhgf
Output:
8
8
Explanation:
ababcabc.cdefghba.Taken from: here.