139.单词拆分
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> bool:
dp = [False]*(len(s)+1)
dp[0] = True
for i in range(1,len(s)+1):
for j in range(i):
if dp[j] == True and s[j:i] in wordDict:
dp[i] = True
return dp[len(s)]
题目链接:139. 单词拆分 - 力扣(LeetCode)