目录

力扣139. 单词拆分

力扣139. Word Break(单词拆分)

给你一个字符串 s 和一个字符串列表 wordDict 作为字典。如果可以利用字典中出现的一个或多个单词拼接出 s 则返回 true。字典中的单词可以重复使用。

示例 1:

../posts/01_学习/87_LeetCode/0139_单词拆分/img/0139-1-description.png

输入:s = "leetcode", wordDict = ["leet","code"]
输出:true
解释:...

示例 2:

../posts/01_学习/87_LeetCode/0139_单词拆分/img/0139-2-description.png

输入:s = "applepenapple", wordDict = ["apple","pen"]
输出:true

提示:

  • 1 <= s.length <= 300
  • 1 <= wordDict.length <= 1000
  • 1 <= wordDict[i].length <= 20