[python] clean sort/set with workthrough O(n log n)
\nclass Solution:\n    """\n    First sort the list by lexicographic orer.\n    \n    Then, iterate through the sorted list. \n    \n    If the length of word i
```\nclass Solution:\n    """\n    First sort the list by lexicographic orer.\n    \n    Then, iterate through the sorted list. \n    \n    If the length of word is 1, just add to hashset.\n    \n    If length larger than one, we need to check whether its [:-1] part in set or not. If so, then\n    it is a candidate for the longest word seen so far. We add the word itself to the hash set to it can be used\n    to form other words.\n    \n    hashset contents example: \n    {\'worl\', \'world\', \'w\', \'wo\', \'wor\'}\n\n    """\n    \n    def longestWord(self, words: List[str]) -> str:\n        words.sort()\n        \n        result = \'\'\n        seen = set()\n        for w in words:\n            if len(w) == 1 or w[0:-1] in seen:\n                if len(w) > len(result):\n                    result = w\n                seen.add(w)\n  \n        return result\n\t\t```
['Sorting', 'Python']