Problems

28. Word Break

MediumDynamic ProgrammingAmazonGoogle

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

Example 1:

Input: s = "leetcode", wordDict = ["leet","code"]
Output: true

Example 2:

Input: s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]
Output: false

Constraints:

  • 1 <= s.length <= 300
  • 1 <= wordDict.length <= 1000
Core code mode
● Auto-savedLine 1, column 1