Given a list of words, return the longest word that can be built one character at a time using other
words of the list: every prefix of the answer (of length 1, 2, ...) must itself be in the list. If several
words qualify with the same maximal length, return the lexicographically smallest. If no word qualifies
return "".
Examples
Input: words = ["tornado", "t", "to", "tone", "tor", "torn"]
Output: "torn"
Explanation: "tornado" is longer but "torna" is missing; "tone" needs "ton", which is missing too.
Input: words = ["b", "be", "bed", "bet", "bead", "beds", "bets", "x"]
Output: "beds"
Explanation: "beds" (from b, be, bed) and "bets" (from b, be, bet) both qualify with length 4,
and "beds" is smaller; "bead" does not qualify because "bea" is missing.
Constraints
- Target:
O(total characters)
Goals
- Traverse a trie while only descending through complete words
- Break ties by lexicographic order