Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ainevsia committed Aug 26, 2023
1 parent 2af9c98 commit f363c70
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions notes/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,5 @@
- [70. 爬楼梯 (进阶)](./day45/lc70.md)
- [322. 零钱兑换](./day45/lc322.md)
- [279.完全平方数](./day45/lc279.md)
- [day 46](./day46.md)
- [remains](./remains.md)
18 changes: 18 additions & 0 deletions notes/src/day46.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 第九章 动态规划part08
● 139.单词拆分
● 关于多重背包,你该了解这些!
● 背包问题总结篇!

详细布置

关于 多重背包,力扣上没有相关的题目,所以今天大家的重点就是回顾一波 自己做的背包题目吧。

## 139.单词拆分
视频讲解:https://www.bilibili.com/video/BV1pd4y147Rh
https://programmercarl.com/0139.%E5%8D%95%E8%AF%8D%E6%8B%86%E5%88%86.html

## 关于多重背包,你该了解这些!
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

## 背包问题总结篇!
https://programmercarl.com/%E8%83%8C%E5%8C%85%E6%80%BB%E7%BB%93%E7%AF%87.html
24 changes: 24 additions & 0 deletions notes/src/day46/lc139.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 139. 单词拆分

不会

```cpp
class Solution {
public:
bool wordBreak(string s, vector<string>& wordDict) {
// dp[i] -> 长度为i的字符串是否可以拼出来
// dp[j] = true if dp[j-i] == true and [i:j] in wordDict
unordered_set<string> wordSet(wordDict.begin(),wordDict.end());
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 ++ ) {
string word = s.substr(j,i-j);
if (dp[j] && wordSet.find(word)!= wordSet.end())
dp[i] = true;
}
}
return dp[s.size()];
}
};
```

0 comments on commit f363c70

Please sign in to comment.