Longest Word in Dictionary
hardFind the longest word that can be built one character at a time
Longest Word in Dictionary
Key Insight
Only traverse trie nodes marked as end of word; every prefix on the route must be valid.
Step 1Insert Words
Array
w
0wo
1wor
2worl
3world
4hello
5hell
6he
7HashMap
w:1
wo:2
wor:3
worl:4
world:5
h:1
he:2
Mark terminals for all words in trie.
1 / 3