題庫
00:00

28. Word Break

中等動態規劃AmazonGoogle

Determine whether s can be segmented into one or more words from wordDict.

範例 1:

輸入: s = "leetcode", wordDict = ["leet","code"]
輸出: true

範例 2:

輸入: s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]
輸出: false

限制條件:

  • 1 <= s.length <= 300
  • 1 <= wordDict.length <= 1000
核心程式碼模式
● 已自動儲存第 1 行,第 1 欄