classSolution:defwordBreak(self,s:str,wordDict: List[str]) -> List[str]: wordDictSet =set(wordDict) ans = []defhelper(s,curr):iflen(s)==0: ans.append(' '.join(curr))returnelse:for word in wordDictSet:iflen(word)<=len(s):if s.startswith(word): curr.append(word)helper(s[len(word):], curr) curr.pop()helper(s, [])return ans