Shortest Common Supersequence
Submissions: 6190   Accuracy:

48.15%

  Difficulty: Easy   Marks: 2
Associated Course(s):   Geeks Classes DSA

Given two strings str1 and str2, find the length of the smallest string which has both, str1 and str2 as its sub-sequences.
Note: str1 and str2 can have both uppercase and lowercase letters.

Input:
The first line of input contains an integer T denoting the number of test cases.Each test case contains two space separated strings.

Output:
For each testcase, in a new line, output the length of the required string.

Constraints:
1 <= T <= 100
1<= |str1|, |str2| <= 100

Example:
Input:

2
abcd xycd
efgh jghi
Output:
6
6

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Shubham Chaudhary
Author: Shubham Chaudhary gfg


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.