Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 961 Bytes

File metadata and controls

26 lines (17 loc) · 961 Bytes

Shortest Common Supersequence

You are given two strings, str1 and str2. Your task is to find the shortest common supersequence (SCS). The shortest possible string that contains both str1 and str2 as subsequences.

If multiple strings satisfy this condition, you may return any one of them.

Note: A string s is considered a subsequence of another string t if s can be obtained by deleting zero or more characters from t without changing the order of the remaining characters.

Constraints

  • 1 <= str1.length, str2.length <= 10^3
  • str1 and str2 consist of lowercase English letters.

Examples

Example 1 Example 2 Example 3 Example 4

Related Topics

  • String
  • Dynamic Programming