Longest Word in Dictionary
Medium · Trie · about 15 minutes
Asked at Google, Amazon, Pinterest, Microsoft.
words contains lowercase words. Find the longest word that can be grown one letter at a time with each intermediate step being a word in the list: all of its prefixes, from length 1 upward, must be present. On a length tie, prefer the alphabetically earliest; return "" if no word qualifies.