Word break
Mediumdynamic programmingstringhash set
Return true if s can be split into words that are all in the dictionary words. A word may be reused.
Example 1
Input: s = "seacode", words = ["sea","code"] Output: true
Example 2
Input: s = "applepenapple", words = ["apple","pen"] Output: true
Example 3
Input: s = "catsandog", words = ["cats","dog","sand","and","cat"] Output: false
Constraints
- 1 ≤ s.length ≤ 300
- 1 ≤ words.length ≤ 1000
Submit checks your solution against 9 tests, including hidden ones.
/**
* @param {string} s
* @param {string[]} words
* @return {bool}
*/
function wordBreak(s, words) {
}