We’re preparing your current view and syncing the latest data.
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may assume the dictionary does not contain duplicate words.
A string s and an array of strings wordDict.
Boolean indicating whether the string can be segmented.
1 <= s.length <= 300 1 <= wordDict.length <= 1000 1 <= wordDict[i].length <= 20 s and wordDict[i] consist of only lowercase English letters.
Example 1
Input
"to
Output
false
Explanation
The string 'to' cannot be segmented into dictionary words if no dictionary is provided.