python
class Solution:
def findAllConcatenatedWordsInADict(self, words: List[str]) -> List[str]:
ws=set(words)
ml=min(map(len,words))
@cache
def is_concat(word):
for i in range(ml,len(word)-ml+1):
if word[:i] in ws and (word[i:] in ws or is_concat(word[i:])):
return True
return False
return [w for w in words if is_concat(w)]
(word[i:] in ws or is_concat(word[i:])注意这一部分代码