File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 150
150
- [ 70. 爬楼梯 (进阶)] ( ./day45/lc70.md )
151
151
- [ 322. 零钱兑换] ( ./day45/lc322.md )
152
152
- [ 279.完全平方数] ( ./day45/lc279.md )
153
+ - [ day 46] ( ./day46.md )
153
154
- [ remains] ( ./remains.md )
Original file line number Diff line number Diff line change
1
+ # 第九章 动态规划part08
2
+ ● 139.单词拆分
3
+ ● 关于多重背包,你该了解这些!
4
+ ● 背包问题总结篇!
5
+
6
+ 详细布置
7
+
8
+ 关于 多重背包,力扣上没有相关的题目,所以今天大家的重点就是回顾一波 自己做的背包题目吧。
9
+
10
+ ## 139.单词拆分
11
+ 视频讲解:https://www.bilibili.com/video/BV1pd4y147Rh
12
+ https://programmercarl.com/0139.%E5%8D%95%E8%AF%8D%E6%8B%86%E5%88%86.html
13
+
14
+ ## 关于多重背包,你该了解这些!
15
+ https://programmercarl.com/%E8%83%8C%E5%8C%85%E9%97%AE%E9%A2%98%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80%E5%A4%9A%E9%87%8D%E8%83%8C%E5%8C%85.html
16
+
17
+ ## 背包问题总结篇!
18
+ https://programmercarl.com/%E8%83%8C%E5%8C%85%E6%80%BB%E7%BB%93%E7%AF%87.html
Original file line number Diff line number Diff line change
1
+ # 139. 单词拆分
2
+
3
+ 不会
4
+
5
+ ``` cpp
6
+ class Solution {
7
+ public:
8
+ bool wordBreak(string s, vector<string >& wordDict) {
9
+ // dp[ i] -> 长度为i的字符串是否可以拼出来
10
+ // dp[ j] = true if dp[ j-i] == true and [ i: j ] in wordDict
11
+ unordered_set<string > wordSet(wordDict.begin(),wordDict.end());
12
+ vector<bool >dp(s.size()+1,false);
13
+ dp[ 0] =true;
14
+ for (int i = 1 ; i<=s.size();i++) {
15
+ for (int j = 0; j < i; j ++ ) {
16
+ string word = s.substr(j,i-j);
17
+ if (dp[ j] && wordSet.find(word)!= wordSet.end())
18
+ dp[ i] = true;
19
+ }
20
+ }
21
+ return dp[ s.size()] ;
22
+ }
23
+ };
24
+ ```
You can’t perform that action at this time.
0 commit comments