Solution Review: Word Formation From a Vector Using a Trie
Learn a detailed analysis of the different ways to solve the “Word Formation From a Vector Using a Trie” challenge.
We'll cover the following...
We'll cover the following...
Solution: Iterative word matching
The algorithm can be divided into three parts. The first and simplest part is making a trie for the words in the dictionary.
The second part is to check if there is a word in the trie which can become a prefix for the query word. In the case of “helloworld,” you can find “he” in the trie. Since there can be multiple prefixes of a word, you have to check for every such prefix. As you iterate through the trie, whenever you find a prefix that exists as a word in the trie, ...