Back to problems Sign in to unlock
Leetcode
Easy
Arrays
Strings
Hash Maps
String Matching in an Array
Find all words that appear as a substring of another word in the same list.
Acceptance 0%
Problem Statement
Given an array of strings, return every word that occurs as a contiguous substring of at least one other word in the array. Each matching word should appear once in the answer, regardless of how many superstrings contain it.
A word is considered a substring of another word if its characters appear consecutively inside that other word.
Input Format
- A list of strings
words. words[i]is a non-empty lowercase string.
Output Format
- Return all strings from
wordsthat are substrings of another string inwords. - The order of the returned strings does not matter unless otherwise specified by the platform.
Constraints
- Strings contain only lowercase English letters.
- Individual string lengths are small enough for pairwise checking in an interview setting.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.