README.md 10.5 KB
Newer Older
S
Songkeys 已提交
1
# LeetCode
L
luzhipeng 已提交
2

S
Songkeys 已提交
3
简体中文 | [English](./README.en.md)
L
luzhipeng 已提交
4

5
---
A
arida 已提交
6

7
![leetcode.jpeg](./assets/leetcode.jpeg)
L
luzhipeng 已提交
8

S
Songkeys 已提交
9
## 介绍
L
luzhipeng 已提交
10

S
Songkeys 已提交
11
leetcode 题解,记录自己的 leetcode 解题之路。
L
luzhipeng 已提交
12

S
Songkeys 已提交
13
本仓库目前分为四个部分:
L
luzhipeng 已提交
14

S
Songkeys 已提交
15
- 第一个部分是 leetcode 经典题目的解析,包括思路,关键点和具体的代码实现。
L
luzhipeng 已提交
16

S
Songkeys 已提交
17
- 第二部分是对于数据结构与算法的总结
L
luzhipeng 已提交
18

S
Songkeys 已提交
19
- 第三部分是 anki 卡片, 将 leetcode 题目按照一定的方式记录在 anki 中,方便大家记忆。
L
luzhipeng 已提交
20

S
Songkeys 已提交
21
- 第四部分是计划, 这里会记录将来要加入到以上三个部分内容
L
luzhipeng 已提交
22

S
Songkeys 已提交
23
> 只有熟练掌握基础的数据结构与算法,才能对复杂问题迎刃有余。
L
luzhipeng 已提交
24

S
Songkeys 已提交
25
## 食用指南
L
luzhipeng 已提交
26

S
Songkeys 已提交
27 28 29 30 31
- 对于最近添加的部分, 后面会有 🆕 标注
- 对于最近更新的部分, 后面会有 🖊 标注
- 将来会在这里更新anki卡片
- 这里有一份leetcode官方账号在知乎上给出的一个《互联网公司最常见的面试算法题有哪些?》的答案,我这里尽量去覆盖回答中的题目和知识点
原文地址: https://www.zhihu.com/question/24964987/answer/586425979
32

S
Songkeys 已提交
33
- 这里有一张互联网公司面试中经常考察的问题类型总结的思维导图,我们可以结合图片中的信息分析一下。
34 35

![leetcode-zhihu](./assets//leetcode-zhihu.jpg)
L
luzhipeng 已提交
36

S
Songkeys 已提交
37 38 39 40 41 42 43 44 45
(图片来自leetcode)

其中算法,主要是以下几种:

- 基础技巧:分治、二分、贪心
- 排序算法:快速排序、归并排序、计数排序
- 搜索算法:回溯、递归、深度优先遍历,广度优先遍历,二叉搜索树等
- 图论:最短路径、最小生成树
- 动态规划:背包问题、最长子序列
L
luzhipeng 已提交
46

S
Songkeys 已提交
47
数据结构,主要有如下几种:
L
luzhipeng 已提交
48

S
Songkeys 已提交
49 50 51 52 53 54
- 数组与链表:单 / 双向链表
- 栈与队列
- 哈希表
- 堆:最大堆 / 最小堆
- 树与图:最近公共祖先、并查集
- 字符串:前缀树(字典树) / 后缀树
L
luzhipeng 已提交
55 56 57



L
luzhipeng 已提交
58

S
Songkeys 已提交
59
## 精彩预告
L
luzhipeng 已提交
60 61


62
[0042.trapping-rain-water](./problems/42.trapping-rain-water.md):
L
luzhipeng 已提交
63

L
luzhipeng 已提交
64
![0042.trapping-rain-water](./assets/problems/42.trapping-rain-water-1.png)
L
luzhipeng 已提交
65

S
Songkeys 已提交
66
[浏览器中的栈](./thinkings/basic-data-structure.md)
L
luzhipeng 已提交
67 68 69

![basic-data-structure-call-stack](./assets/thinkings/basic-data-structure-call-stack.png)

70
[backtrack problems](./problems/90.subsets-ii.md):
L
luzhipeng 已提交
71

L
luzhipeng 已提交
72
![backtrack](./assets/problems/backtrack.png)
L
luzhipeng 已提交
73

74
[0198.house-robber](./problems/198.house-robber.md):
L
luzhipeng 已提交
75

L
luzhipeng 已提交
76 77
![198.house-robber](./assets/problems/198.house-robber.png)

78
[0454.4-sum-ii](./problems/454.4-sum-ii.md):
L
luzhipeng 已提交
79 80

![454.4-sum-ii](./assets/problems/454.4-sum-ii.png)
L
luzhipeng 已提交
81

S
Songkeys 已提交
82
## Top题目进度
L
luzhipeng 已提交
83

L
luzhipeng 已提交
84
- [Top 100 Linked Questions](https://leetcode.com/problemset/top-100-liked-questions/) (45 / 100)
L
luzhipeng 已提交
85

L
luzhipeng 已提交
86
- [Top Interview Questions](https://leetcode.com/problemset/top-interview-questions/) (65 / 145)
S
Songkeys 已提交
87
## 传送门
L
luzhipeng 已提交
88

S
Songkeys 已提交
89
### leetcode 经典题目的解析
L
luzhipeng 已提交
90

S
Songkeys 已提交
91
> 这里仅列举具有代表性题目,并不是全部题目
L
luzhipeng 已提交
92

S
Songkeys 已提交
93
#### 简单难度
L
luzhipeng 已提交
94

L
luzhipeng 已提交
95
- [0020.Valid Parentheses](./problems/20.validParentheses.md)
L
luzhipeng 已提交
96
- [0026.remove-duplicates-from-sorted-array](./problems/26.remove-duplicates-from-sorted-array.md)
L
luzhipeng 已提交
97
- [0088.merge-sorted-array](./problems/88.merge-sorted-array.md)
L
luzhipeng 已提交
98 99
- [0121.best-time-to-buy-and-sell-stock](./problems/121.best-time-to-buy-and-sell-stock.md)
- [0122.best-time-to-buy-and-sell-stock-ii](./problems/122.best-time-to-buy-and-sell-stock-ii.md)
L
luzhipeng 已提交
100 101
- [0136.single-number](./problems/136.single-number.md)
- [0167.two-sum-ii-input-array-is-sorted](./problems/167.two-sum-ii-input-array-is-sorted.md)
L
luzhipeng 已提交
102
- [0172.factorial-trailing-zeroes](./problems/172.factorial-trailing-zeroes.md) 🆕
L
luzhipeng 已提交
103
- [0169.majority-element](./problems/169.majority-element.md)
L
luzhipeng 已提交
104 105
- [0190.reverse-bits](./problems/190.reverse-bits.md)
- [0191.number-of-1-bits](./problems/191.number-of-1-bits.md)
106
- [0198.house-robber](./problems/198.house-robber.md) 🆕
L
luzhipeng 已提交
107 108 109 110
- [0203.remove-linked-list-elements](./problems/203.remove-linked-list-elements.md)
- [0206.reverse-linked-list](./problems/206.reverse-linked-list.md)
- [0219.contains-duplicate-ii](./problems/219.contains-duplicate-ii.md)
- [0226.invert-binary-tree](./problems/226.invert-binary-tree.md)
L
luzhipeng 已提交
111
- [0263.ugly-number](./problems/263.ugly-number.md) 🆕
L
luzhipeng 已提交
112
- [0283.move-zeroes](./problems/283.move-zeroes.md)
L
luzhipeng 已提交
113
- [0342.power-of-four](./problems/342.power-of-four.md) 🆕
L
luzhipeng 已提交
114
- [0349.intersection-of-two-arrays](./problems/349.intersection-of-two-arrays.md)
L
luzhipeng 已提交
115
- [0575.distribute-candies](./problems/575.distribute-candies.md) 🆕
L
luzhipeng 已提交
116

L
luzhipeng 已提交
117

S
Songkeys 已提交
118
#### 中等难度
L
luzhipeng 已提交
119

L
luzhipeng 已提交
120 121 122
- [0002. Add Two Numbers](./problems/2.addTwoNumbers.md)
- [0003. Longest Substring Without Repeating Characters](./problems/3.longestSubstringWithoutRepeatingCharacters.md)
- [0011.container-with-most-water](./problems/11.container-with-most-water.md)
L
luzhipeng 已提交
123
- [0015.3-sum](./problems/15.3-sum.md)
L
luzhipeng 已提交
124 125
- [0019. Remove Nth Node From End of List](./problems/19.removeNthNodeFromEndofList.md)
- [0024. Swap Nodes In Pairs](./problems/24.swapNodesInPairs.md)
L
luzhipeng 已提交
126 127 128 129
- [0039.combination-sum](./problems/39.combination-sum.md)
- [0040.combination-sum-ii](./problems/40.combination-sum-ii.md)
- [0046.permutations](./problems/46.permutations.md)
- [0047.permutations-ii](./problems/47.permutations-ii.md)
L
luzhipeng 已提交
130 131 132
- [0055.jump-game](./problems/55.jump-game.md) 🆕 
- [0062.unique-paths](./problems/62.unique-paths.md )🆕 
- [0075.sort-colors](./problems/75.sort-colors.md)
L
luzhipeng 已提交
133
- [0078.subsets](./problems/78.subsets.md)
L
luzhipeng 已提交
134
- [0086.partition-list](./problems/86.partition-list.md)
L
luzhipeng 已提交
135 136
- [0090.subsets-ii](./problems/90.subsets-ii.md)
- [0091.decode-ways](./problems/91.decode-ways.md) 🆕 
L
luzhipeng 已提交
137 138 139 140 141 142 143 144 145 146
- [0092.reverse-linked-list-ii](./problems/92.reverse-linked-list-ii.md)
- [0094.binary-tree-inorder-traversal](./problems/94.binary-tree-inorder-traversal.md)
- [0102.binary-tree-level-order-traversal](./problems/102.binary-tree-level-order-traversal.md)
- [0103.binary-tree-zigzag-level-order-traversal](./problems/103.binary-tree-zigzag-level-order-traversal.md)
- [0139.word-break](./problems/139.word-breakmd)
- [0144.binary-tree-preorder-traversal](./problems/144.binary-tree-preorder-traversal.md)
- [0150.evaluate-reverse-polish-notation](./problems/150.evaluate-reverse-polish-notation.md) 🖊
- [0152.maximum-product-subarray](./problems/152.maximum-product-subarray.md) 🆕  
- [0199.binary-tree-right-side-view](./problems/199.binary-tree-right-side-view.md)
- [0201.bitwise-and-of-numbers-range](./problems/201.bitwise-and-of-numbers-range.md)
L
luzhipeng 已提交
147
- [0208.implement-trie-prefix-tree](./problems/208.implement-trie-prefix-tree.md)
L
luzhipeng 已提交
148 149 150 151
- [0209.minimum-size-subarray-sum](./problems/209.minimum-size-subarray-sum.md) 🖊 
- [0236.lowest-common-ancestor-of-a-binary-tree](./problems/236.lowest-common-ancestor-of-a-binary-tree.md)🆕 
- [0238.product-of-array-except-self](./problems/238.product-of-array-except-self.md) 🆕 
- [0240.search-a-2-d-matrix-ii](./problems/240.search-a-2-d-matrix-ii.md)
L
luzhipeng 已提交
152 153
- [0279.perfect-squares](./problems/279.perfect-squares.md)
- [0309.best-time-to-buy-and-sell-stock-with-cooldown](./problems/309.best-time-to-buy-and-sell-stock-with-cooldown.md) 🆕 
L
luzhipeng 已提交
154 155
- [0322.coin-change](./problems/322.coin-change.md)
- [0328.odd-even-linked-list](./problems/328.odd-even-linked-list.md)
L
luzhipeng 已提交
156 157
- [0334.increasing-triplet-subsequence](./problems/334.increasing-triplet-subsequence.md)
- [0365.water-and-jug-problem](./problems/365.water-and-jug-problem.md) 🆕 
L
luzhipeng 已提交
158 159
- [0416.partition-equal-subset-sum](./problems/416.partition-equal-subset-sum.md)
- [0445.add-two-numbers-ii](./problems/445.add-two-numbers-ii.md)
L
luzhipeng 已提交
160
- [0454.4-sum-ii](./problems/454.4-sum-ii.md) 🆕
L
luzhipeng 已提交
161
- [0494.target-sum](./problems/494.target-sum.md)
L
luzhipeng 已提交
162
- [0518.coin-change-2](./problems/518.coin-change-2.md)
L
luzhipeng 已提交
163
- [0609.find-duplicate-file-in-system](./problems/609.find-duplicate-file-in-system.md) 🆕
L
luzhipeng 已提交
164 165 166 167
- [0875.koko-eating-bananas](./problems/875.koko-eating-bananas.md)
- [0877.stone-game](./problems/877.stone-game.md)
- [0887.super-egg-drop](./problems/887.super-egg-drop.md)
- [0900.rle-iterator](./problems/900.rle-iterator.md)
L
luzhipeng 已提交
168

S
Songkeys 已提交
169
#### 困难难度
L
luzhipeng 已提交
170 171 172 173 174 175
- [0023.merge-k-sorted-lists](./problems/23.merge-k-sorted-lists.md)
- [0042.trapping-rain-water](./problems/42.trapping-rain-water.md)
- [0128.longest-consecutive-sequence](./problems/128.longest-consecutive-sequence.md) 🆕 
- [0145.binary-tree-postorder-traversal](./problems/145.binary-tree-postorder-traversal.md)
- [0146.lru-cache](./problems/146.lru-cache.md)
- [0239.sliding-window-maximum](./problems/239.sliding-window-maximum.md)
176
- [0295.find-median-from-data-stream](./problems/295.find-median-from-data-stream.md) 🆕 
L
luzhipeng 已提交
177
- [0301.remove-invalid-parentheses](./problems/301.remove-invalid-parentheses.md)
L
luzhipeng 已提交
178

S
Songkeys 已提交
179
### 数据结构与算法的总结
L
luzhipeng 已提交
180

S
Songkeys 已提交
181 182 183 184 185
- 🖊 [数据结构](./thinkings/basic-data-structure.md)(草稿)
- 🖊 [二叉树的遍历](./thinkings/binary-tree-traversal.md)
- [动态规划](./thinkings/dynamic-programming.md)
- [哈夫曼编码和游程编码](./thinkings/run-length-encode-and-huffman-encode.md)
- [布隆过滤器](./thinkings/bloom-filter.md)
L
luzhipeng 已提交
186

S
Songkeys 已提交
187
### anki 卡片
188

S
Songkeys 已提交
189
Anki主要分为两个部分:一部分是关键点到题目的映射,另一部分是题目到思路,关键点,代码的映射。
190

S
Songkeys 已提交
191
全部卡片都在[anki-card](./assets/anki/leetcode.apkg)
192

S
Songkeys 已提交
193
使用方法:
L
luzhipeng 已提交
194

S
Songkeys 已提交
195
anki - 文件 - 导入 - 下拉格式选择“打包的 anki集合”,然后选中你下载好的文件,确定即可。
L
luzhipeng 已提交
196

S
Songkeys 已提交
197
更多关于anki使用方法的请查看[anki官网](https://apps.ankiweb.net/)
L
luzhipeng 已提交
198

S
Songkeys 已提交
199
目前已更新卡片一览(仅列举正面):
200

L
luzhipeng 已提交
201
- 二分法解决问题的关键点是什么,相关问题有哪些?
S
Songkeys 已提交
202 203 204 205
- 如何用栈的特点来简化操作, 涉及到的题目有哪些?
- 双指针问题的思路以及相关题目有哪些?
- 滑动窗口问题的思路以及相关题目有哪些?
- 回溯法解题的思路以及相关题目有哪些?
L
luzhipeng 已提交
206 207 208 209
- 数论解决问题的关键点是什么,相关问题有哪些?
- 位运算解决问题的关键点是什么,相关问题有哪些?

> 已加入的题目有:#2 #3 #11
210

S
Songkeys 已提交
211
### 计划
L
luzhipeng 已提交
212

S
Songkeys 已提交
213
- [anki 卡片 完善](./assets/anki/)
214

S
Songkeys 已提交
215
- [字符串类问题汇总](./todo/str/)
L
luzhipeng 已提交
216

S
Songkeys 已提交
217
## 交流群
L
luzhipeng 已提交
218

S
Songkeys 已提交
219
现在还是初级阶段,需要大家的意见和反馈,为了减少沟通成本,我组建了交流群。大家可以扫码进入
L
dp  
luzhipeng 已提交
220

S
Songkeys 已提交
221
### QQ 群
L
luzhipeng 已提交
222

L
luzhipeng 已提交
223
![qq-group-chat](./assets/qq-group-chat.png)
L
luzhipeng 已提交
224

S
Songkeys 已提交
225
### 微信群
L
luzhipeng 已提交
226

L
luzhipeng 已提交
227
![wechat-group-chat](./assets/wechat-group-chat.jpeg)
L
luzhipeng 已提交
228

S
Songkeys 已提交
229 230 231
(由于微信的限制,100个人以上只能邀请加入, 你可以添加我的机器人回复“leetcode”拉你进群)

### Telegram
232

S
Songkeys 已提交
233
http://t.me/leetcode_intl
234

L
luzhipeng 已提交
235

S
Songkeys 已提交
236
## 贡献
L
luzhipeng 已提交
237

S
Songkeys 已提交
238 239 240
- 如果有想法和创意,请提[issue](https://github.com/azl397985856/leetcode/issues)或者进群提
- 如果想贡献代码,请提[PR](https://github.com/azl397985856/leetcode/pulls)
- 如果需要修改项目中图片,[这里](./assets/drawio/)存放了项目中绘制图的源代码, 大家可以用[draw.io](https://www.draw.io/)打开进行编辑。