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.
Input Format
Input is managed for you
Output Format
Output is managed for you
Constraints
1. 1 <= words.length <= 1000 2. 1 <= words[i].length <= 30 3. words[i] consists of lowercase English letters.
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
7 a banana app appl ap apply apple
Output
apple