[Python] O(n log(n)) Time, O(n) Space Faster Than 95%
\nclass Solution:\n    def longestWord(self, words: List[str]) -> str:\n        words.sort()                  # for smallest lexicographical order\n        visi
```\nclass Solution:\n    def longestWord(self, words: List[str]) -> str:\n        words.sort()                  # for smallest lexicographical order\n        visited = {""}                # hashset to keep a track of visited words\n        res = \'\'\n        \n        for word in words:\n            if word[:-1] in visited:     # check previous word ie. word[:len(word)-1] visited or not\n                visited.add(word)        # add this word to the set\n                if len(word) > len(res): # current word have greater lenght and lexicographically smaller\n                    res = word           # update res\n        \n        return res\n    \n    \n    \n# Time: O(n log(n))   # for sorting the words\n# Space: O(n)         # for making the set visited\n```\n\nSolution using Trie+BFS: https://leetcode.com/problems/longest-word-in-dictionary/discuss/2075062/Trie+BFS-or-Python-Solution-with-Comments-Easy-to-Understand
['Ordered Set', 'Python', 'Python3']