Word Break
Given a string s and a dictionary wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Words may be reused any number of times.
Open official problem prompt ↗Determine whether the whole string can be tiled end-to-end using dictionary words with repetition allowed.
Laying floor tiles of fixed shapes: you can cover the hallway only if some sequence of available tiles reaches the far wall with no gaps.
- Input
- s = "leetcode", wordDict = ["leet", "code"]
- Output
- true
- Why
- "leetcode" splits into "leet" + "code", both in the dictionary.
1 <= s.length <= 3001 <= wordDict.length <= 10001 <= wordDict[i].length <= 20s and wordDict[i] consist of only lowercase English lettersAll dictionary words are unique