word-break-ii
时间限制:1秒 空间限制:32768K 热度指数:20435
本题知识点: 动态规划 leetcode
算法知识视频讲解

题目描述


Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.

Return all such possible sentences.

For example, given
s ="catsanddog",
dict =["cat", "cats", "and", "sand", "dog"].

A solution is["cats and dog", "cat sand dog"].