← 返回 google 的题目列表String Word Break
类型:online_judge
Given a string s and a dictionary of words wordDict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
Input
A string s and a set of strings wordDict.
Output
Return True if s can be segmented, False otherwise.
Example
Input: s = "leetcode", wordDict = ["leet", "code"] Output: True
Input: s = "applepenapple", wordDict = ["apple", "pen"] Output: True
Constraints
1 <= len(s) <= 300
1 <= wordDict.length <= 1000
Note
The word dictionary wordDict may contain duplicate words.
Example
Input
"leetcode"
["leet","code"]