Longest Word In Dictionary
medium
1. Given an array of strings words. 2. Find the word of longest length, where all of its substrings starting from 0th index exists as different word in array. 3. If there are multiple answers with same length return one which is smallest in lexicographical order. If there is no valid string return empty string.
Constraints
1. 1 <= words.length <= 1000 2. 1 <= words[i].length <= 30 3. words[i] consists of lowercase English letters.
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
7
a
banana
app
appl
ap
apply
apple
Sample Output
apple