Concatenated Words
Given an array of strings words (without duplicates), return all the concatenated words in the given list. A concatenated word is a string that is comprised entirely of at least two shorter words in the given array.

30:00

Concatenated Words
hard
Topics
Companies

Given an array of strings words (without duplicates), return all the concatenated words in the given list. A concatenated word is a string that is comprised entirely of at least two shorter words in the given array.

Example 1:
Input: {"words":["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"]}
Output: ["catsdogcats","dogcatsdog","ratcatdogcat"]
Constraints:
  • 1words.length1041 \leq \text{words.length} \leq 10^4

  • 1words[i].length301 \leq \text{words}[i].\text{length} \leq 30

  • words[i]\text{words}[i] consists of only lowercase English letters.

  • All strings in words are unique.

  • 1words[i].length1051 \leq \sum \text{words}[i].\text{length} \leq 10^5

Input
arr ={"words":["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"]}

8 words in the dictionary. A word counts if it splits into two or more of the others.

State
words
["cat", "cats", "catsdogcats", "dog", "dogcatsdog", "hippopotamuses", "rat", "ratcatdogcat"]
wordCount
8
found
[]
Variables
words=8
Variables
VariableValue
words8
DepthFunction Call
Stack empty
0/82