Tap here to switch tabs
Problem
Submissions

Problem: Shortest Common Supersequence

Shortest Common Supersequence asks you to combine two strings into the shortest string that contains both as subsequences; return any valid answer when multiple shortest strings exist.

Statement

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 ss is considered a subsequence of another string tt if ss can be obtained by deleting zero or more characters from tt without changing the order of the remaining characters.

Constraints:

  • 1≤1 \leq str1.length, str2.length ≤103\leq 10^3

  • str1 and str2 consist of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Shortest Common Supersequence

Shortest Common Supersequence asks you to combine two strings into the shortest string that contains both as subsequences; return any valid answer when multiple shortest strings exist.

Statement

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 ss is considered a subsequence of another string tt if ss can be obtained by deleting zero or more characters from tt without changing the order of the remaining characters.

Constraints:

  • 1≤1 \leq str1.length, str2.length ≤103\leq 10^3

  • str1 and str2 consist of lowercase English letters.