Given a string s and a dictionary of words dict of length n, add spaces in s to construct a sentence where each word is a valid dictionary word. Each dictionary word can be used more than once. Return all such possible sentences.
Follow examples for better understanding.
- Time : O(s^2)
- Space : O(dict)
c++
1 | struct Trie{ |