Given a list of words, return the longest word that can be built one character at a time, where every prefix of it (of every length) is also a word in the list. On ties, return the lexicographically smallest. Return an empty line if no word qualifies.
Input: one line of space-separated words. Output: the answer word (or empty).
w wo wor worl world
world
a banana app appl ap apply apple
apple
apple and apply tie at length 5; apple is smaller.
abc bd
No single-letter starting point.
Run your code against the sample tests, or Submit to run the full suite.