Skip to content

Commit 0074cb1

Browse files
committed
update: 前缀和系列
1 parent 0233dcd commit 0074cb1

11 files changed

+659
-479
lines changed

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
- [专题篇](#专题篇)
3030
- [二分法](#二分法)
3131
- [滑动窗口](#滑动窗口)
32+
- [每日一题](#每日一题-5)
33+
- [拓展题目](#拓展题目)
3234
- [位运算](#位运算)
3335
- [搜索(BFS, DFS, 回溯)](#搜索bfs-dfs-回溯)
3436
- [背包问题](#背包问题)
3537
- [动态规划](#动态规划)
3638
- [分治](#分治)
3739
- [贪心](#贪心)
38-
- [每日一题](#每日一题-5)
40+
- [每日一题](#每日一题-6)
3941
- [贪心拓展题目](#贪心拓展题目)
4042
- [其他](#其他)
4143

@@ -192,10 +194,18 @@
192194
- [x] [【day-38】20.有效括号](./medium/hot/38.valid-parentheses.md)
193195
- [x] [【day-38】32.最长有效括号](./medium/hot/38.longest-valid-parentheses.md)
194196

195-
**其他**
197+
**设计系列**
198+
199+
- [ ] [【day-39】剑指 Offer09.用两个栈实现队列](./)
200+
- [ ] [【day-39】641.设计循环双端队列](./)
201+
- [x] [【day-39】146.LRU 缓存机制](./basic/linked-list/12.lru-cache.md)
202+
- [ ] [【day-39】1206.设计跳表](./)
203+
204+
**前缀和系列**
196205

197-
- [x] [前缀和系列](./medium/day-39.md)
198-
- [x] [581.最短无序连续子数组](./medium/day-34.md)
206+
- [x] [【day-40】网易面试题](./medium/hot/40.netease.md)
207+
- [x] [【day-40】560.和为 K 的子数组](./medium/hot/40.subarray-sum-equals-k.md)
208+
- [x] [【day-40】1371.每个元音包含偶数次的最长子字符串](./medium/hot/40.find-the-longest-substring-containing-vowels-in-even-counts.md)
199209

200210
### 前缀树
201211

@@ -244,10 +254,16 @@
244254

245255
### 滑动窗口
246256

257+
#### 每日一题
258+
247259
- [x] [【day-68】1456.定长子串中元音的最大数目](./topics/day-68.md)
248260
- [ ] [【day-70】76.最小覆盖子串](./topics/day-70.md)
249261
- [ ] [【day-71】30.串联所有单词的子串](./topics/day-71.md)
250262

263+
#### 拓展题目
264+
265+
- [x] [581.最短无序连续子数组](./topics/sliding-window/ext-shortest-unsorted-continuous-subarray.md)
266+
251267
### 位运算
252268

253269
- [ ] [【day-72】268.缺失数字](./topics/day-72.md)

algorithms/greedy.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 贪心算法
2+
3+
## 简介
4+
5+
贪心算法就是,在每次操作时都做出**当下最好**的选择,从而使最后得到的结果是最优解。做出局部选择时,**不考虑这个选择对将来的影响**,而且做出选择之后**不会回退到以前**。因为全局结果是局部结果的简单求和,且**局部结果互不相干**,所以**局部最优策略**也就是全局最优策略。
6+
7+
但并不是所有问题都可以使用贪心算法得到最优解,重点是**贪婪策略**的选择,难点在于如何证明局部最优解就可以得到全局最优解。
8+
9+
贪心算法有点像动态规划,只不过,每个局部选择都只依靠另**一个**局部选择。要证明贪心算法能够得到全局最优解,只需要证明在填表 (动态规划的状态表) 的时候,每填一个格子我们只需要查询另一个格子,而不需要综合考虑几个格子。因为贪心算法每次只考虑一个子问题,所以解决问题的时间复杂度一般是线性的。
10+
11+
## 算法
12+
13+
- 初始化结果数组
14+
- 在每一步中,把当前项加入结果数组中
15+
- 如果此时结果数组是一个可行解,那就保留当前项
16+
- 如果不是,那就去除当前项,并且之后不再考虑这一项
17+
18+
## 相关题目类型
19+
20+
### 分配问题
21+
22+
- [455.分发饼干](https://github.com/suukii/91-days-algorithm/blob/master/topics/greedy/ext-assign-cookies.md)
23+
- [135.分发糖果](https://github.com/suukii/91-days-algorithm/blob/master/topics/greedy/ext-candy.md)
24+
25+
### 区间问题
26+
27+
- [435.无重叠区间](https://github.com/suukii/91-days-algorithm/blob/master/topics/greedy/ext-non-overlapping-intervals.md)
28+
29+
TODO
30+
31+
- [ ] http://web.stanford.edu/class/archive/cs/cs161/cs161.1176/Lectures/CS161Lecture14.pdf
32+
- [ ] http://web.stanford.edu/class/archive/cs/cs161/cs161.1176/Sections/final_review-1.pdf
33+
- [ ] file:///H:/Algorithm/LeetCode%20101%20-%20A%20LeetCode%20Grinding%20Guide%20(C++%20Version).pdf

medium/day-34.md

Lines changed: 0 additions & 166 deletions
This file was deleted.

0 commit comments

Comments
 (0)