Word Break II
HardBacktracking
Decode it first. Clues, constraints, pattern and plan before any code.Given a string s and a list of dictionary words wordDict, add spaces to s so that every resulting word is in the dictionary. Return all such sentences, in any order. A dictionary word may be reused any number of times.
s = "catsanddog", wordDict = ["cat", "cats", "and", "sand", "dog"]
→ ["cats and dog", "cat sand dog"]
s = "catsandog", wordDict = ["cats", "dog", "sand", "and", "cat"]
→ []Constraints
1 <= s.length <= 201 <= wordDict.length <= 10001 <= wordDict[i].length <= 10- All the words in
wordDictare unique.