Problem
Return true if the string s can be split into a sequence of one or more words from word_dict. Words may be reused any number of times.
Example 1
- Input
- s = "pineapple", word_dict = ["pine", "apple", "pen"]
- Output
- true
Example 2
- Input
- s = "catsandog", word_dict = ["cats", "dog", "sand", "and", "cat"]
- Output
- false
Example 3
- Input
- s = "aaaa", word_dict = ["aa"]
- Output
- true
- Why
- "aa" twice
An empty string counts as breakable.
Constraints
0 <= s.length <= 3001 <= word_dict.length <= 10001 <= word_dict[i].length <= 20s and every word contain only lowercase letters.