 All Problems
Word Break II
hard
strings
dynamic programming
backtracking
trie
google
amazon
facebook
microsoft

Given string s and a dictionary, return all possible sentences where every word is in the dictionary. Print each sentence on a new line in sorted order.

Example:

Input: catsanddog
       cat cats and sand dog
Output: cat sand dog
        cats and dog

Input format: Line 1 = s, line 2 = space-separated dictionary.

Run to check your code against the sample cases, or submit to run every case