Skip to content

Practice Shortest String That Contains Three Strings

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2800
LeetCode Problem

Shortest String That Contains Three Strings

Problem Statement

Find a shortest string containing a, b and c as contiguous substrings. When several shortest strings qualify, return the lexicographically smallest one.

Source: Shortest String That Contains Three Strings on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
a = "abc", b = "bca", c = "aaa"
Output
"aaabca"

# Example 2

Input
a = "ab", b = "ba", c = "aba"
Output
"aba"

Constraints

1 <= a.length, b.length, c.length <= 100
a, b, c consist only of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Shortest String That Contains Three Strings.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.