/*
还是和决策树一样,从s的第0个位置开始遍历,
然后只要word是s的子串,那么则置为true,而且要注意边界条件
*/
class Solution {
public:
bool wordBreak(string s, vector<string>& wordDict) {
vector<bool> dp(s.length()+1,false);
dp0=true;
for(int i=0;i<s.length();i++){
for(auto word : wordDict){
if(dpi&&(i+word.length()<=s.length())&&word==s.substr(i,word.length())){
dpi+word.length()=dpi;
}
}
}
return dps.length();
}
};