lc139.单词拆分 Leetcode dp Jan 19, 2021 题目链接 一个动态规划的题目,可以联想成完全背包问题。这个算法的时间复杂度是O(N^2),空间复杂度是O(N)。 python: class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> bool: size = len(s) dp = [False]*(size+1) dp[0] = True for i in range(size): for j in range(i+1, size+1): if dp[i] and s[i:j] in wordDict: dp[j] = True return dp[-1] PREVIOUSmq059.最小路径和NEXTmq062.单词拆分