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"]}

Find all concatenated words from 8 words

State
wordCount
8
Variables
No variables to display
DepthFunction Call
Stack empty
0/4