Practice Find the Shortest Superstring
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Hard#943
LeetCode ProblemFind the Shortest Superstring
Problem Statement
Given an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of the smallest length, return any of them. You may assume that no string in words is a substring of another string in words.
Source: Find the Shortest Superstring on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
words = ["alex","loves","leetcode"]
Output
"alexlovesleetcode"
# Example 2
Input
words = ["catg","ctaagt","gcta","ttca","atgcatc"]
Output
"gctaagttcatgcatc"
Constraints
1 <= words.length <= 12
1 <= words[i].length <= 20
words[i] consists of lowercase English letters.
All the strings of words are unique.
Related LeetCode Problems
Practice more problems similar to Find the Shortest Superstring.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.