Back to course home
0% completed
Solution: Concatenated Words
Problem Statement
Given a words
array containing non-duplicate strings, return all the concatenated words
that are in the words
array.
A concatenated word
is a string that is formed entirely of at least two shorter words (May be same) of the given array.
Examples
- Example 1:
- Input: words =
["tree","cat","cattree","dog","catdog"]
- Expected Output:
["cattree", "catdog"]
- Justification: 'cattree' is formed by concatenating 'cat' and 'tree'. Similarly, 'catdog' is a combination of 'cat' and 'dog'
- Input: words =
.....
.....
.....
Like the course? Get enrolled and start learning!