vocabulary, an array of words. A word can be *grown* if you can reach it by starting from a one-letter word and appending one letter at a time, with every intermediate word also present in the dictionary. In other words, every non-empty prefix of the word must be in the dictionary.
Return the longest word in the dictionary that can be grown. If several such words share the maximum length, return the alphabetically smallest one. If no word can be grown, return the empty string.vocabulary=['s', 'st', 'sta', 'star', 'start', 'stars', 'tar'] → 'stars'
Both start and stars grow letter by letter: s → st → sta → star → … Both have length 5, and stars comes first alphabetically.
vocabulary=['ox', 'oxen', 'b'] → 'b'
There is no one-letter o, so neither ox nor oxen can be built. Only b is left.
vocabulary=['go', 'gone'] → ''
No word can be grown from a single letter, so the answer is the empty string.
len(vocabulary) ≤ 1000len(vocabulary[i]) ≤ 30vocabulary=['s', 'st', 'sta', 'star', 'start', 'stars', 'tar']
'stars'
Run checks the first 3 tests in your browser. Submit checks all 117 tests on the server, hidden ones included.