...

/

DIY: Concatenated Words

DIY: Concatenated Words

We'll cover the following...

Problem statement

Provided a list of strings, words, with unique elements, return all the concatenated words in the given list.

A word that is a combination of at least two or more words is known as a concatenated word.

Input

The input will be a list of strings. The following is an example input:

["cat", "dog", "cats", "lion", "catsdog"]

Output

The output will be a list of concatenated words that exist in words. The following is an example output:

["catsdog"]

The string catsdog is the only word made up of cats and dog that exist in the list.

Coding exercise

Implement the find_all_concatenated_words(words) function, where words is the list of strings. The function will return a list of concatenated strings.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy