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 dictionary words (a word may be used more than once), otherwise false; the empty string needs no words and returns true.
Examples
Example 1
{
"s": "rainbow",
"wordDict": ["rain", "bow"]
}Output: true
Example 2
{
"s": "applepen",
"wordDict": ["apple", "pen"]
}Output: true
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.