README.md 7.3 KB
Newer Older
A
arida 已提交
1
# 介绍
L
luzhipeng 已提交
2

L
luzhipeng 已提交
3 4
![leetcode.jpeg](./assets/leetcode.jpeg)

L
luzhipeng 已提交
5
leetcode 题解,记录自己的 leetcode 解题之路。
A
arida 已提交
6

L
luzhipeng 已提交
7 8 9 10 11 12 13 14 15 16 17 18
本仓库目前分为四个部分:

- 第一个部分是 leetcode 经典题目的解析,包括思路,关键点和具体的代码实现。

- 第二部分是对于数据结构与算法的总结

- 第三部分是 anki 卡片, 将 leetcode 题目按照一定的方式记录在 anki 中,方便大家记忆。

- 第四部分是计划, 这里会记录将来要加入到以上三个部分内容

> 只有熟练掌握基础的数据结构与算法,才能对复杂问题迎刃有余

L
luzhipeng 已提交
19
## 食用指南
L
luzhipeng 已提交
20

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

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

![leetcode-zhihu](./assets//leetcode-zhihu.jpg)

(图片来自leetcode)

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

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

L
luzhipeng 已提交
41 42 43 44 45 46 47 48 49 50 51
数据结构,主要有如下几种:

- 数组与链表:单 / 双向链表
- 栈与队列
- 哈希表
- 堆:最大堆 / 最小堆
- 树与图:最近公共祖先、并查集
- 字符串:前缀树(字典树) / 后缀树



L
luzhipeng 已提交
52 53 54 55

## 精彩预告


L
luzhipeng 已提交
56
42.trapping-rain-water-1(雨水收集问题):
L
luzhipeng 已提交
57

L
luzhipeng 已提交
58
![42.trapping-rain-water](./assets/problems/42.trapping-rain-water-1.png)
L
luzhipeng 已提交
59 60 61 62 63

浏览器中的栈:

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

L
luzhipeng 已提交
64
再看动态规划:
L
luzhipeng 已提交
65 66 67 68 69 70 71

![dynamic-programming-3](./assets/thinkings/dynamic-programming-3.png)

875. koko-eating-bananas:

![koko-eating-bananas](./assets/problems/koko-eating-bananas.png)

A
arida 已提交
72
## 传送门
L
luzhipeng 已提交
73

L
luzhipeng 已提交
74 75 76
### leetcode 经典题目的解析

#### 简单难度
L
luzhipeng 已提交
77

L
luzhipeng 已提交
78 79
- [20. Valid Parentheses](./problems/validParentheses.md)
- [26.remove-duplicates-from-sorted-array](./problems/26.remove-duplicates-from-sorted-array.md)
80
- 🆕 [88.merge-sorted-array](./problems/88.merge-sorted-array.md)
L
luzhipeng 已提交
81 82
- [136.single-number](./problems/136.single-number.md)
- [167.two-sum-ii-input-array-is-sorted](./problems/167.two-sum-ii-input-array-is-sorted.md)
L
luzhipeng 已提交
83 84 85
- 🆕 [169.majority-element](./problems/169.majority-element.md)
- [190.reverse-bits](./problems/190.reverse-bits.md)
- [191.number-of-1-bits](./problems/191.number-of-1-bits.md)
L
luzhipeng 已提交
86
- [203.remove-linked-list-elements](./problems/203.remove-linked-list-elements.md)
L
luzhipeng 已提交
87
- [206.reverse-linked-list](./problems/206.reverse-linked-list.md)
L
luzhipeng 已提交
88
- [219.contains-duplicate-ii](./problems/219.contains-duplicate-ii.md)
L
luzhipeng 已提交
89
- [226.invert-binary-tree](./problems/226.invert-binary-tree.md)
L
luzhipeng 已提交
90 91
- [283.move-zeroes](./problems/283.move-zeroes.md)
- [349.intersection-of-two-arrays](./problems/349.intersection-of-two-arrays.md)
L
luzhipeng 已提交
92

L
luzhipeng 已提交
93

L
luzhipeng 已提交
94
#### 中等难度
L
luzhipeng 已提交
95

L
luzhipeng 已提交
96 97
- [2. Add Two Numbers](./problems/addTwoNumbers.md)
- [3. Longest Substring Without Repeating Characters](./problems/longestSubstringWithoutRepeatingCharacters.md)
98
- [11.container-with-most-water](./problems/11.container-with-most-water.md)
L
luzhipeng 已提交
99 100
- [19. Remove Nth Node From End of List](./problems/removeNthNodeFromEndofList.md)
- [24. Swap Nodes In Pairs](./problems/swapNodesInPairs.md)
L
luzhipeng 已提交
101
- [55.jump-game.md](./problems/55.jump-game.md.md)
L
luzhipeng 已提交
102
- [75.sort-colors.md](./problems/75.sort-colors.md)
L
luzhipeng 已提交
103 104 105 106 107
- [86.partition-list](./problems/86.partition-list.md)
- [92.reverse-linked-list-ii](./problems/92.reverse-linked-list-ii.md)
- [94.binary-tree-inorder-traversal](./problems/94.binary-tree-inorder-traversal.md)
- [102.binary-tree-level-order-traversal](./problems/102.binary-tree-level-order-traversal.md)
- [103.binary-tree-zigzag-level-order-traversal](./problems/103.binary-tree-zigzag-level-order-traversal.md)
L
luzhipeng 已提交
108
- 🆕 [139.word-break](./problems/139.word-breakmd)
L
luzhipeng 已提交
109 110 111
- [144.binary-tree-preorder-traversal](./problems/144.binary-tree-preorder-traversal.md)
- [150.evaluate-reverse-polish-notation](./problems/150.evaluate-reverse-polish-notation.md)
- [199.binary-tree-right-side-view](./problems/199.binary-tree-right-side-view.md)
L
luzhipeng 已提交
112
- [201.bitwise-and-of-numbers-range](./problems/201.bitwise-and-of-numbers-range.md)
L
luzhipeng 已提交
113
- [208.implement-trie-prefix-tree](./problems/208.implement-trie-prefix-tree.md)
L
luzhipeng 已提交
114
- [209.minimum-size-subarray-sum](./problems/209.minimum-size-subarray-sum.md)
L
luzhipeng 已提交
115 116
- 🆕 [240.search-a-2-d-matrix-ii](./problems/240.search-a-2-d-matrix-ii.md)
- [279.perfect-squares](./problems/279.perfect-squares.md)
L
luzhipeng 已提交
117
- [322.coin-change](./problems/322.coin-change.md)
L
luzhipeng 已提交
118
- [328.odd-even-linked-list](./problems/328.odd-even-linked-list.md)
L
luzhipeng 已提交
119
- 🆕 [416.partition-equal-subset-sum](./problems/416.partition-equal-subset-sum.md)
L
luzhipeng 已提交
120
- [445.add-two-numbers-ii](./problems/445.add-two-numbers-ii.md)
L
luzhipeng 已提交
121
- [518.coin-change-2](./problems/518.coin-change-2.md)
122
- [875.koko-eating-bananas](./problems/875.koko-eating-bananas.md)
L
luzhipeng 已提交
123 124 125
- [877.stone-game](./problems/877.stone-game.md)
- 🆕 [887.super-egg-drop](./problems/887.super-egg-drop.md)
- [900.rle-iterator](./problems/900.rle-iterator.md)
L
luzhipeng 已提交
126

L
luzhipeng 已提交
127
#### 困难难度
L
luzhipeng 已提交
128 129
- [42.trapping-rain-water](./problems/42.trapping-rain-water.md)
- [128.longest-consecutive-sequence](./problems/128.longest-consecutive-sequence.md)
L
luzhipeng 已提交
130 131
- [145.binary-tree-postorder-traversal](./problems/145.binary-tree-postorder-traversal.md)
- [146.lru-cache](./problems/146.lru-cache.md)
L
luzhipeng 已提交
132
- 🆕 [295.find-median-from-data-stream.md](./problems/295.find-median-from-data-stream.md)
L
luzhipeng 已提交
133
- [301.remove-invalid-parentheses](./problems/301.remove-invalid-parentheses.md)
L
luzhipeng 已提交
134 135 136

### 数据结构与算法的总结

L
luzhipeng 已提交
137
- 🖊 [basic-data-structure](./thinkings/basic-data-structure.md)(草稿)
138
- [binary-tree-traversal](./thinkings/binary-tree-traversal.md)
L
luzhipeng 已提交
139
- [dynamic-programming](./thinkings/dynamic-programming.md)
L
luzhipeng 已提交
140
- [哈夫曼编码和游程编码](./thinkings/run-length-encode-and-huffman-encode.md)
L
luzhipeng 已提交
141
- [布隆过滤器](./thinkings/bloom-filter.md)
L
luzhipeng 已提交
142 143 144

### anki 卡片

145 146
Anki主要分为两个部分:一部分是关键点到题目的映射,另一部分是题目到思路,关键点,代码的映射。

L
luzhipeng 已提交
147
全部卡片都在[anki-card](./assets/anki/leetcode.apkg)
148 149 150 151 152 153

使用方法:

anki - 文件 - 导入 - 下拉格式选择“打包的 anki集合”,然后选中你下载好的文件,确定即可。

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

### 计划

L
luzhipeng 已提交
157 158 159 160 161
- [494.target-sum](./todo/494.target-sum.js)

- [609.find-duplicate-file-in-system](./todo/609.find-duplicate-file-in-system.js)

- [10.regular-expression-matching](./todo/10.regular-expression-matching.js)
L
luzhipeng 已提交
162

L
luzhipeng 已提交
163
- [365.water-and-jug-problem](./todo/365.water-and-jug-problem.js)
L
luzhipeng 已提交
164

165
- anki 卡片 完善
L
luzhipeng 已提交
166 167

## 交流群
L
dp  
luzhipeng 已提交
168

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

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

L
luzhipeng 已提交
173
(qq 群)
L
luzhipeng 已提交
174

L
luzhipeng 已提交
175
![wechat-group-chat](./assets/wechat-group-chat.jpg)
L
luzhipeng 已提交
176

L
luzhipeng 已提交
177
(微信群, 由于微信的限制,只可以七天之内才能加入)