5380. 数组中的字符串匹配
python 字符串长度排序
class Solution:
def stringMatching(self, words: List[str]) -> List[str]:
res = []
words = sorted(words, key=lambda x: len(x))
for i, word in enumerate(words):
for j in range(i+1, len(words)):
if word in words[j]:
res.append(word)
break
return res