medium
Word Break
Given a string and a dictionary of words, decide whether the string can be split into a sequence of dictionary words. Words may be reused.
Constraints
- 1 ≤ s.length ≤ 300
- 1 ≤ wordDict.length ≤ 1000
- 1 ≤ word length ≤ 20
- Lowercase letters
Examples
in: s = "leetcode", wordDict = ["leet","code"]
out: true
in: s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]
out: false
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.