12 - Shortest Common Supersequence - Definition

@Rishi Srivastava In computer science, the shortest common supersequence (SCS) of two sequences X and Y is the shortest sequence which has X and Y as subsequences. A shortest common supersequence is a common supersequence of minimal length. In the shortest common supersequence problem, two sequences X and Y are given, and the task is to find a shortest possible common supersequence of these sequences. In general, an SCS is not unique. Problem: Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If there are multiple valid strings, return any of them. Example: Input: str1 = “abac“, str2 = “cab“ Output: “cabac“ Explanation: str1 = “abac“ is a subsequence of “cabac“ because we can delete the first “c“. str2 = “cab“ is a subsequence of “cabac“ because we can delete the last “ac“. The answer provided is the shortest such
Back to Top