首页 > 试题广场 >

possible sentences

[编程题]possible sentences
  • 热度指数:1859 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
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.


输入描述:
s ="catsanddog"
dict ="cat", "cats", "and", "sand", "dog"


输出描述:
[cats and dog, cat sand dog]
示例1

输入

s ="catsanddog"
dict ="cat","cats","and","sand","dog"

输出

[cats and dog, cat sand dog]

这道题你会答吗?花几分钟告诉大家答案吧!