参考:https://algorithm.yuanbin.me/zh-hans/dynamic_programming/word_break.html
class Solution {
public:
bool wordBreak(string s, vector<string>& wordDict) {
vector<bool> dp(s.size() + 1, false);
dp[0] = true;
for(int i = 1; i <= s.size(); i++){
for(int j = 0; j < i; j++){
if(find(wordDict.begin(), wordDict.end(),s.substr(j, i - j)) != wordDict.end() && dp[j] == true){
dp[i] = true;
continue;
}
}
}
return dp[s.size()];
}
};