求推荐blue ray播放器# Living
s*m
1 楼
leetcode原题word breakII,输出一种分割即可
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"].
我考虑的做法是,先动态规划找到可分割的点dp[n+1],然后倒着遍历s,查找单词。
follow up: 英语中,几个字母组成单词的概率远小于不是单词的概率,怎么优化?
follow问题,该怎么优化????????????
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"].
我考虑的做法是,先动态规划找到可分割的点dp[n+1],然后倒着遍历s,查找单词。
follow up: 英语中,几个字母组成单词的概率远小于不是单词的概率,怎么优化?
follow问题,该怎么优化????????????