O(N*L) |  O(N*L) | Python Solution | Explained
Hello Tenno Leetcoders, \n\nFor this problem, we want to return all  non duplicated concatenated words\n\nThis problem has the same logic as 139. Word Break. Th
Hello **Tenno Leetcoders**, \n\nFor this problem, we want to return all  non duplicated `concatenated words`\n\nThis problem has the same logic as `139. Word Break`. This problem has its differences though because we want only words that are concatenated by 2 or more other words\n\nWe can use `Dynamic Programming` to break the problem down and try to form a single word by using words in our array.\n\n### Dynamic Programming\n\n1) Iterate over our given array and try to form a word by checking if each given word is a `concatenation` of other words\n\n2) If we found a word that is a concatenation of other words, we will add it to our result\n\n\n\n### Code\n```\ndef findAllConcatenatedWordsInADict(self, words: List[str]) -> List[str]:\n        \n        words_set = set(words)\n      \n        result = []\n    \n        def dfs(word):\n            for i in range(len(word)):\n  \n                if word[:i+1] in words_set and word[i+1:] in words_set:\n                    return True\n\t\t\t\t\t\n                if word[:i+1] in words_set and dfs(word[i+1:]):\n                    return True\n\n            return False\n    \n        for word in words:\n            if dfs(word):\n                result.append(word)\n        return result\n```\n\n#### Time Complexity: O(N*L)\n#### Space Complexity: O(N*L)\n\n\n***Upvote if this tenno\'s discussion helped you in some type of way***\n \n***Warframe\'s short pvp clip of the day***\n![image](https://assets.leetcode.com/users/images/4b75b9d6-ac59-479a-b2e9-82211507948a_1674843889.7265222.gif)\n
['Dynamic Programming', 'Python', 'Python3']