Shortest Common Supersequence
Given two strings str1 and str2, return the shortest string that contains both of them as subsequences.
A string contains another as a subsequence when the second can be obtained by deleting zero or more characters from the first without reordering the rest. Concatenating the two inputs always produces a supersequence; the task is to find the shortest one.
str1 = "abac", str2 = "cab"
"cabac"
Deleting the leading c from "cabac" leaves "abac", and deleting the b and the final c leaves "cab". No string of length 4 contains both, and "cabac" is the only string of length 5 that does.
str1 = "abcde", str2 = "ace"
"abcde"
"ace" is already a subsequence of "abcde", so nothing has to be added and the longer string is itself the answer.
1 <= str1.length, str2.length <= 1000str1andstr2consist of lowercase English letters- Each test case has exactly one shortest common supersequence, so the answer is compared as an exact string