Medium · Strings
Word break
Given a string s and a list of dictionary words wordDict, return true if s can be split into a sequence of one or more dictionary words (a word may be used more than once), otherwise false.
Examples
Example 1
{
"s": "rainbow",
"wordDict": ["rain", "bow"]
}Output: true
Example 2
{
"s": "applepen",
"wordDict": ["apple", "pen"]
}Output: true
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.