Skip to content

#139 - Word Break

MediumDP - 1D
Open on LeetCode

Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. The same word may be reused multiple times.

InputOutput
s = "leetcode", wordDict = ["leet","code"]true
s = "applepenapple", wordDict = ["apple","pen"]true
s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]false

Released under the MIT License.