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