Concatenated Words
hard
Given an array of strings words, return all the concatenated words in the given list of words. Concatenated word is a word that can be created by concatination of at least two other shorter words from the list. You can return concatination words in any order
Constraints
1. 1 <= words.length <= 10^4 2. 1 <= words[i].length <= 1000 3. words[i] consists of only lowercase English letters. 4. all word's in the list are unique. 5. 0 <= sum(words[i].length) <= 10^5
Format
Input
n count of words in list word1 word2 ... n words
Output
Output is managed for you
Example
Sample Input
8
cat
cats
catsdogcats
dog
dogcatsdog
hippopotamuses
rat
ratcatdogcat
Sample Output
catsdogcats
dogcatsdog
ratcatdogcat