class Solution:
def longestWord(self, words: List[str]) -> str:
"""
:type words: List[str]
:rtype: str
"""
words.sort()
save = set() #用list存储的话,后面搜索会比较慢
res = ""
for word in words:
if word[:-1] in save or word[:-1] == '': #单字母的单词 word[:-1] == ''
if len(word) > len(res):
res = word
save.add(word)
return res