Challenge: Word Formation from a Dictionary Using Trie

This is a more advanced problem regarding tries and shows us the efficiency of this data structure in word matching.

Problem Statement #

You have to implement the isFormationPossible() function which will determine whether a given word can be formed by combining two words from a given dictionary.

Input #

A dictionary and a query word.

Output #

Returns true if the given word can be generated by combining two words from the dictionary.

Sample Input #

dict = ["the", "hello", "there", "answer", "any",
                     "by", "world", "their","abc"]
word = "helloworld"

Sample Output #

true

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.