Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5f19bca

Browse files
easyuigitbook-bot
authored andcommittedSep 16, 2020
GitBook: [master] 28 pages and 2 assets modified
1 parent de39717 commit 5f19bca

File tree

16 files changed

+565
-614
lines changed

16 files changed

+565
-614
lines changed
 

‎README.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# 算法模板
1+
# 前言
22

3-
![来刷题了](https://img.fuiboom.com/img/title.png)
3+
![来刷题了](https://img.fuiboom.com/img/title.png)
44

55
算法模板,最科学的刷题方式,最快速的刷题路径,一个月从入门到 offer,你值得拥有 🐶~
66

@@ -11,6 +11,7 @@
1111
> 这个模板主要是介绍了一些通用的刷题模板,以及一些常见问题,如到底要刷多少题,按什么顺序来刷题,如何提高刷题效率等。
1212
1313
## 在线文档
14+
1415
Github: [https://github.com/easyui/algorithm-pattern-swift](https://github.com/easyui/algorithm-pattern-swift) ⭐️
1516

1617
在线文档 Gitbook:[算法模板 🔥](https://zyj.gitbook.io/algorithm-pattern-swift/)
@@ -19,40 +20,40 @@ Github: [https://github.com/easyui/algorithm-pattern-swift](https://github.com/e
1920

2021
### 入门篇 🐶
2122

22-
- [swift 语言入门](./introduction/swift.md)
23-
- [算法快速入门](./introduction/quickstart.md)
23+
* [swift 语言入门](ru-men-pian/swift.md)
24+
* [算法快速入门](ru-men-pian/quickstart.md)
2425

2526
### 数据结构篇 🐰
2627

27-
- [二叉树](./data_structure/binary_tree.md)
28-
- [链表](./data_structure/linked_list.md)
29-
- [栈和队列](./data_structure/stack_queue.md)
30-
- [二进制](./data_structure/binary_op.md)
28+
* [二叉树](shu-ju-jie-gou-pian/binary_tree.md)
29+
* [链表](shu-ju-jie-gou-pian/linked_list.md)
30+
* [栈和队列](shu-ju-jie-gou-pian/stack_queue.md)
31+
* [二进制](shu-ju-jie-gou-pian/binary_op.md)
3132

3233
### 基础算法篇 🐮
3334

34-
- [二分搜索](./basic_algorithm/binary_search.md)
35-
- [排序算法](./basic_algorithm/sort.md)
36-
- [动态规划](./basic_algorithm/dp.md)
35+
* [二分搜索](ji-chu-suan-fa-pian/binary_search.md)
36+
* [排序算法](ji-chu-suan-fa-pian/sort.md)
37+
* [动态规划](ji-chu-suan-fa-pian/dp.md)
3738

3839
### 算法思维 🦁
3940

40-
- [递归思维](./advanced_algorithm/recursion.md)
41-
- [滑动窗口思想](./advanced_algorithm/slide_window.md)
42-
- [二叉搜索树](./advanced_algorithm/binary_search_tree.md)
43-
- [回溯法](./advanced_algorithm/backtrack.md)
41+
* [递归思维](suan-fa-si-wei/recursion.md)
42+
* [滑动窗口思想](suan-fa-si-wei/slide_window.md)
43+
* [二叉搜索树](suan-fa-si-wei/binary_search_tree.md)
44+
* [回溯法](suan-fa-si-wei/backtrack.md)
4445

4546
## 心得体会
4647

4748
文章大部分是对题目的思路介绍,和一些问题的解析,有了思路还是需要自己手动写写的,所以每篇文章最后都有对应的练习题
4849

4950
刷完这些练习题,基本对数据结构和算法有自己的认识体会,基本大部分面试题都能写得出来,国内的 BAT、TMD 应该都不是问题
5051

51-
从 4 月份找工作开始,从 0 开始刷 LeetCode,中间大概花了一个半月(6 周)左右时间刷完 240 题。
52+
从 4 月份找工作开始,从 0 开始刷 LeetCode,中间大概花了一个半月\(6 周\)左右时间刷完 240 题。
5253

53-
![一个半月刷完240题](https://img.fuiboom.com/img/leetcode_time.png)
54+
![一个半月刷完240题](https://img.fuiboom.com/img/leetcode_time.png)
5455

55-
![刷题记录](https://img.fuiboom.com/img/leetcode_record.png)
56+
![刷题记录](https://img.fuiboom.com/img/leetcode_record.png)
5657

5758
开始刷题时,确实是无从下手,因为从序号开始刷,刷到几道题就遇到 hard 的题型,会卡住很久,后面去评论区看别人怎么刷题,也去 Google 搜索最好的刷题方式,发现按题型刷题会舒服很多,基本一个类型的题目,一天能做很多,慢慢刷题也不再枯燥,做起来也很有意思,最后也收到不错的 offer(最后去了宇宙系)。
5859

@@ -66,15 +67,15 @@ Github: [https://github.com/easyui/algorithm-pattern-swift](https://github.com/e
6667

6768
1、 [algorithm-pattern 练习题](https://zyj.gitbook.io/algorithm-pattern-swift/)
6869

69-
![练习题](https://img.fuiboom.com/img/repo_practice.png)
70+
![练习题](https://img.fuiboom.com/img/repo_practice.png)
7071

7172
2、 [LeetCode 卡片](https://leetcode-cn.com/explore/)
7273

73-
![探索卡片](https://img.fuiboom.com/img/leetcode_explore.png)
74+
![探索卡片](https://img.fuiboom.com/img/leetcode_explore.png)
7475

7576
3、 [剑指 offer](https://leetcode-cn.com/problemset/lcof/)
7677

77-
![剑指offer](https://img.fuiboom.com/img/leetcode_jzoffer.png)
78+
![剑指offer](https://img.fuiboom.com/img/leetcode_jzoffer.png)
7879

7980
刷题时间可以合理分配,如果打算准备面试了,建议前面两部分 一个半月 (6 周)时间刷完,最后剑指 offer 半个月刷完,边刷可以边投简历进行面试,遇到不会的不用着急,往模板上套就对了,如果面试管给你提示,那就好好做,不要错过这大好机会~
8081

@@ -96,10 +97,11 @@ Github: [https://github.com/easyui/algorithm-pattern-swift](https://github.com/e
9697

9798
完成计划之后,可以提交 Pull requests,在下面添加自己的项目仓库,完成自己的算法模板打卡呀~
9899

99-
| 完成 | 用户 | 项目地址 |
100-
| ---- | ------------------------------------------------- | ------------------------------------------------------------------- |
101-
|| [greyireland](https://github.com/greyireland/) | [algorithm-pattern(Go 实现)](https://github.com/greyireland/algorithm-pattern) |
102-
|| [easyui](https://github.com/easyui/) | [algorithm-pattern-swift(Swift 实现)](https://github.com/easyui/algorithm-pattern-swift),[在线文档 Gitbook](https://zyj.gitbook.io/algorithm-pattern-swift/) |
103-
|| [wardseptember](https://github.com/wardseptember) | [notes(Java 实现)](https://github.com/wardseptember/notes) |
104-
|| [dashidhy](https://github.com/dashidhy) | [algorithm-pattern-python(Python 实现)](https://github.com/dashidhy/algorithm-pattern-python) |
105-
|| [binzi56](https://github.com/binzi56) | [algorithm-pattern-c(c++ 实现)](https://github.com/binzi56/algorithm-pattern-c) |
100+
| 完成 | 用户 | 项目地址 |
101+
| :--- | :--- | :--- |
102+
|| [greyireland](https://github.com/greyireland/) | [algorithm-pattern\(Go 实现\)](https://github.com/greyireland/algorithm-pattern) |
103+
|| [easyui](https://github.com/easyui/) | [algorithm-pattern-swift\(Swift 实现\)](https://github.com/easyui/algorithm-pattern-swift),[在线文档 Gitbook](https://zyj.gitbook.io/algorithm-pattern-swift/) |
104+
|| [wardseptember](https://github.com/wardseptember) | [notes\(Java 实现\)](https://github.com/wardseptember/notes) |
105+
|| [dashidhy](https://github.com/dashidhy) | [algorithm-pattern-python\(Python 实现\)](https://github.com/dashidhy/algorithm-pattern-python) |
106+
|| [binzi56](https://github.com/binzi56) | [algorithm-pattern-c\(c++ 实现\)](https://github.com/binzi56/algorithm-pattern-c) |
107+

‎SUMMARY.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
# 算法模板
1+
# Table of contents
2+
3+
* [前言](README.md)
24

35
## 入门篇
46

5-
- [swift 语言入门](introduction/swift.md)
6-
- [算法快速入门](introduction/quickstart.md)
7+
* [swift 语言入门](ru-men-pian/swift.md)
8+
* [算法快速入门](ru-men-pian/quickstart.md)
79

810
## 数据结构篇
911

10-
- [二叉树](data_structure/binary_tree.md)
11-
- [链表](data_structure/linked_list.md)
12-
- [栈和队列](data_structure/stack_queue.md)
13-
- [二进制](data_structure/binary_op.md)
12+
* [二叉树](shu-ju-jie-gou-pian/binary_tree.md)
13+
* [链表](shu-ju-jie-gou-pian/linked_list.md)
14+
* [栈和队列](shu-ju-jie-gou-pian/stack_queue.md)
15+
* [二进制](shu-ju-jie-gou-pian/binary_op.md)
1416

1517
## 基础算法篇
1618

17-
- [二分搜索](basic_algorithm/binary_search.md)
18-
- [排序算法](basic_algorithm/sort.md)
19-
- [动态规划](basic_algorithm/dp.md)
19+
* [二分搜索](ji-chu-suan-fa-pian/binary_search.md)
20+
* [排序算法](ji-chu-suan-fa-pian/sort.md)
21+
* [动态规划](ji-chu-suan-fa-pian/dp.md)
2022

2123
## 算法思维
2224

23-
- [递归思维](advanced_algorithm/recursion.md)
24-
- [滑动窗口思想](advanced_algorithm/slide_window.md)
25-
- [二叉搜索树](advanced_algorithm/binary_search_tree.md)
26-
- [回溯法](advanced_algorithm/backtrack.md)
25+
* [递归思维](suan-fa-si-wei/recursion.md)
26+
* [滑动窗口思想](suan-fa-si-wei/slide_window.md)
27+
* [二叉搜索树](suan-fa-si-wei/binary_search_tree.md)
28+
* [回溯法](suan-fa-si-wei/backtrack.md)
29+

‎basic_algorithm/binary_search.md renamed to ‎ji-chu-suan-fa-pian/binary_search.md

Lines changed: 58 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66

77
模板四点要素
88

9-
- 1、初始化:start=0、end=len-1
10-
- 2、循环退出条件:start + 1 < end
11-
- 3、比较中点和目标值:A[mid] ==、 <、> target
12-
- 4、判断最后两个元素是否符合:A[start]、A[end] ? target
9+
* 1、初始化:start=0、end=len-1
10+
* 2、循环退出条件:start + 1 &lt; end
11+
* 3、比较中点和目标值:A\[mid\] ==、 &lt;&gt; target
12+
* 4、判断最后两个元素是否符合:A\[start\]、A\[end\] ? target
1313

14-
时间复杂度 O(logn),使用场景一般是有序数组的查找
14+
时间复杂度 O\(logn\),使用场景一般是有序数组的查找
1515

1616
典型示例
1717

1818
[binary-search](https://leetcode-cn.com/problems/binary-search/)
1919

20-
> 给定一个  n  个元素有序的(升序)整型数组  nums 和一个目标值  target  ,写一个函数搜索  nums  中的 target,如果目标值存在返回下标,否则返回 -1。
20+
> 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target ,写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。
2121
2222
```swift
2323
func search(_ nums: [Int], _ target: Int) -> Int {
2424
var start = 0
2525
var end = nums.count - 1
26-
26+
2727
while start + 1 < end {
2828
let mid = (end + start)/2
2929
if nums[mid] == target {
@@ -38,24 +38,24 @@ func search(_ nums: [Int], _ target: Int) -> Int {
3838
if nums[start] == target {
3939
return start
4040
}
41-
41+
4242
if nums[end] == target {
4343
return end
4444
}
45-
45+
4646
return -1
4747
}
4848
```
4949

5050
大部分二分查找类的题目都可以用这个模板,然后做一点特殊逻辑即可
5151

52-
另外二分查找还有一些其他模板如下图,大部分场景模板#3 都能解决问题,而且还能找第一次/最后一次出现的位置,应用更加广泛
52+
另外二分查找还有一些其他模板如下图,大部分场景模板\#3 都能解决问题,而且还能找第一次/最后一次出现的位置,应用更加广泛
5353

54-
![binary_search_template](https://img.fuiboom.com/img/binary_search_template.png)
54+
![binary\_search\_template](https://img.fuiboom.com/img/binary_search_template.png)
5555

56-
所以用模板#3 就对了,详细的对比可以这边文章介绍:[二分搜索模板](https://leetcode-cn.com/explore/learn/card/binary-search/212/template-analysis/847/)
56+
所以用模板\#3 就对了,详细的对比可以这边文章介绍:[二分搜索模板](https://leetcode-cn.com/explore/learn/card/binary-search/212/template-analysis/847/)
5757

58-
如果是最简单的二分搜索,不需要找第一个、最后一个位置、或者是没有重复元素,可以使用模板#1,代码更简洁
58+
如果是最简单的二分搜索,不需要找第一个、最后一个位置、或者是没有重复元素,可以使用模板\#1,代码更简洁
5959

6060
```swift
6161
// 无重复元素搜索时,更方便
@@ -66,7 +66,7 @@ func search(_ nums: [Int], _ target: Int) -> Int {
6666
func search(_ nums: [Int], _ target: Int) -> Int {
6767
var start = 0
6868
var end = nums.count - 1
69-
69+
7070
while start <= end {
7171
let mid = (end + start)/2
7272
if nums[mid] == target {
@@ -88,8 +88,7 @@ func search(_ nums: [Int], _ target: Int) -> Int {
8888

8989
### [search-for-range](https://www.lintcode.com/problem/search-for-a-range/description)
9090

91-
> 给定一个包含 n 个整数的排序数组,找出给定目标值 target 的起始和结束位置。
92-
> 如果目标值不在数组中,则返回`[-1, -1]`
91+
> 给定一个包含 n 个整数的排序数组,找出给定目标值 target 的起始和结束位置。 如果目标值不在数组中,则返回`[-1, -1]`
9392
9493
思路:核心点就是找第一个 target 的索引,和最后一个 target 的索引,所以用两次二分搜索分别找第一次和最后一次的位置
9594

@@ -99,10 +98,10 @@ func searchRange(_ nums: [Int], _ target: Int) -> [Int] {
9998
guard nums.count != 0 else {
10099
return result
101100
}
102-
101+
103102
var start = 0
104103
var end = nums.count - 1
105-
104+
106105
while start + 1 < end {
107106
let mid = (end + start)/2
108107
if nums[mid] == target {
@@ -113,7 +112,7 @@ func searchRange(_ nums: [Int], _ target: Int) -> [Int] {
113112
start = mid
114113
}
115114
}
116-
115+
117116
// 搜索左边的索引
118117
if nums[start] == target {
119118
result[0] = start
@@ -122,10 +121,10 @@ func searchRange(_ nums: [Int], _ target: Int) -> [Int] {
122121
} else {
123122
return [-1,-1]
124123
}
125-
124+
126125
start = 0
127126
end = nums.count - 1
128-
127+
129128
while start + 1 < end {
130129
let mid = (end + start)/2
131130
if nums[mid] == target {
@@ -136,7 +135,7 @@ func searchRange(_ nums: [Int], _ target: Int) -> [Int] {
136135
start = mid
137136
}
138137
}
139-
138+
140139
// 搜索右边的索引
141140
if result[end] == target {
142141
result[1] = end
@@ -145,7 +144,7 @@ func searchRange(_ nums: [Int], _ target: Int) -> [Int] {
145144
} else {
146145
return [-1,-1]
147146
}
148-
147+
149148
return result
150149
}
151150
```
@@ -162,7 +161,7 @@ func searchRange(_ nums: [Int], _ target: Int) -> [Int] {
162161
func searchInsert(_ nums: [Int], _ target: Int) -> Int {
163162
var start = 0
164163
var end = nums.count - 1
165-
164+
166165
while start + 1 < end {
167166
let mid = (end + start)/2
168167
if nums[mid] == target {
@@ -173,7 +172,7 @@ func searchInsert(_ nums: [Int], _ target: Int) -> Int {
173172
start = mid
174173
}
175174
}
176-
175+
177176
if nums[start] >= target {
178177
return start
179178
}else if nums[end] >= target {
@@ -186,10 +185,10 @@ func searchInsert(_ nums: [Int], _ target: Int) -> Int {
186185

187186
### [search-a-2d-matrix](https://leetcode-cn.com/problems/search-a-2d-matrix/)
188187

189-
> 编写一个高效的算法来判断  m x n  矩阵中,是否存在一个目标值。该矩阵具有如下特性:
188+
> 编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性:
190189
>
191-
> - 每行中的整数从左到右按升序排列。
192-
> - 每行的第一个整数大于前一行的最后一个整数。
190+
> * 每行中的整数从左到右按升序排列。
191+
> * 每行的第一个整数大于前一行的最后一个整数。
193192
194193
```swift
195194
//https://leetcode-cn.com/problems/search-a-2d-matrix/solution/swift-m-x-nju-zhen-ke-yi-shi-wei-chang-du-wei-m-x-/
@@ -205,10 +204,10 @@ func searchMatrix(_ matrix: [[Int]], _ target: Int) -> Bool {
205204
if n == 0 {
206205
return false
207206
}
208-
207+
209208
var start = 0
210209
var end = m * n - 1
211-
210+
212211
while start <= end {
213212
let mid = (end + start)/2
214213
let midValue = matrix[mid/n][mid%n]
@@ -220,15 +219,14 @@ func searchMatrix(_ matrix: [[Int]], _ target: Int) -> Bool {
220219
end = mid - 1
221220
}
222221
}
223-
222+
224223
return false
225224
}
226225
```
227226

228227
### [first-bad-version](https://leetcode-cn.com/problems/first-bad-version/)
229228

230-
> 假设你有 n 个版本 [1, 2, ..., n],你想找出导致之后所有版本出错的第一个错误的版本。
231-
> 你可以通过调用  bool isBadVersion(version)  接口来判断版本号 version 是否在单元测试中出错。实现一个函数来查找第一个错误的版本。你应该尽量减少对调用 API 的次数。
229+
> 假设你有 n 个版本 \[1, 2, ..., n\],你想找出导致之后所有版本出错的第一个错误的版本。 你可以通过调用 bool isBadVersion\(version\) 接口来判断版本号 version 是否在单元测试中出错。实现一个函数来查找第一个错误的版本。你应该尽量减少对调用 API 的次数。
232230
233231
```swift
234232
//https://leetcode-cn.com/problems/first-bad-version/solution/swift-er-fen-cha-zhao-by-hu-cheng-he-da-bai-sha-3/
@@ -255,8 +253,7 @@ func firstBadVersion(n int) int {
255253

256254
### [find-minimum-in-rotated-sorted-array](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/)
257255

258-
> 假设按照升序排序的数组在预先未知的某个点上进行了旋转( 例如,数组  [0,1,2,4,5,6,7] 可能变为  [4,5,6,7,0,1,2] )。
259-
> 请找出其中最小的元素。
256+
> 假设按照升序排序的数组在预先未知的某个点上进行了旋转\( 例如,数组 \[0,1,2,4,5,6,7\] 可能变为 \[4,5,6,7,0,1,2\] \)。 请找出其中最小的元素。
260257
261258
```swift
262259
//https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/solution/swift-er-fen-cha-zhao-by-hu-cheng-he-da-bai-sha-4/
@@ -265,7 +262,7 @@ func firstBadVersion(n int) int {
265262
func findMin(_ nums: [Int]) -> Int {
266263
var start = 0
267264
var end = nums.count - 1
268-
265+
269266
while start + 1 < end {
270267
let mid = (start + end)/2
271268
// if nums[mid] > nums[start] && nums[mid] > nums[end] {
@@ -287,9 +284,7 @@ func findMin(_ nums: [Int]) -> Int {
287284

288285
### [find-minimum-in-rotated-sorted-array-ii](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/)
289286

290-
> 假设按照升序排序的数组在预先未知的某个点上进行了旋转
291-
> ( 例如,数组  [0,1,2,4,5,6,7] 可能变为  [4,5,6,7,0,1,2] )。
292-
> 请找出其中最小的元素。(包含重复元素)
287+
> 假设按照升序排序的数组在预先未知的某个点上进行了旋转 \( 例如,数组 \[0,1,2,4,5,6,7\] 可能变为 \[4,5,6,7,0,1,2\] \)。 请找出其中最小的元素。\(包含重复元素\)
293288
294289
```swift
295290
//https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/solution/swift-er-fen-cha-zhao-gen-ju-153ti-bi-jiao-qian-qu/
@@ -299,9 +294,9 @@ func findMin(_ nums: [Int]) -> Int {
299294
func findMin(_ nums: [Int]) -> Int {
300295
var start = 0
301296
var end = nums.count - 1
302-
297+
303298
while start + 1 < end {
304-
299+
305300
while start + 1 < end {
306301
if nums[start] == nums[start + 1] {
307302
start += 1
@@ -316,7 +311,7 @@ func findMin(_ nums: [Int]) -> Int {
316311
break
317312
}
318313
}
319-
314+
320315
let mid = (start + end)/2
321316
if nums[mid] > nums[end] {
322317
start = mid
@@ -330,10 +325,7 @@ func findMin(_ nums: [Int]) -> Int {
330325

331326
### [search-in-rotated-sorted-array](https://leetcode-cn.com/problems/search-in-rotated-sorted-array/)
332327

333-
> 假设按照升序排序的数组在预先未知的某个点上进行了旋转。
334-
> ( 例如,数组  [0,1,2,4,5,6,7]  可能变为  [4,5,6,7,0,1,2] )。
335-
> 搜索一个给定的目标值,如果数组中存在这个目标值,则返回它的索引,否则返回  -1 。
336-
> 你可以假设数组中不存在重复的元素。
328+
> 假设按照升序排序的数组在预先未知的某个点上进行了旋转。 \( 例如,数组 \[0,1,2,4,5,6,7\] 可能变为 \[4,5,6,7,0,1,2\] \)。 搜索一个给定的目标值,如果数组中存在这个目标值,则返回它的索引,否则返回 -1 。 你可以假设数组中不存在重复的元素。
337329
338330
```swift
339331
//https://leetcode-cn.com/problems/search-in-rotated-sorted-array/solution/swift-er-fen-cha-zhao-que-ren-midhe-targetde-wei-z/
@@ -345,10 +337,10 @@ func search(_ nums: [Int], _ target: Int) -> Int {
345337
} else if nums.count == 1 {
346338
return nums[0] == target ? 0 : -1
347339
}
348-
340+
349341
var start = 0
350342
var end = nums.count - 1
351-
343+
352344
while start + 1 < end {
353345
let mid = (start + end)/2
354346
if target == nums[mid] {
@@ -383,9 +375,7 @@ func search(_ nums: [Int], _ target: Int) -> Int {
383375
384376
### [search-in-rotated-sorted-array-ii](https://leetcode-cn.com/problems/search-in-rotated-sorted-array-ii/)
385377

386-
> 假设按照升序排序的数组在预先未知的某个点上进行了旋转。
387-
> ( 例如,数组  [0,0,1,2,2,5,6]  可能变为  [2,5,6,0,0,1,2] )。
388-
> 编写一个函数来判断给定的目标值是否存在于数组中。若存在返回  true,否则返回  false。(包含重复元素)
378+
> 假设按照升序排序的数组在预先未知的某个点上进行了旋转。 \( 例如,数组 \[0,0,1,2,2,5,6\] 可能变为 \[2,5,6,0,0,1,2\] \)。 编写一个函数来判断给定的目标值是否存在于数组中。若存在返回 true,否则返回 false。\(包含重复元素\)
389379
390380
```swift
391381
//https://leetcode-cn.com/problems/search-in-rotated-sorted-array-ii/solution/swift-zai-33ti-ji-chu-shang-bi-jiao-qian-xian-qu-c/
@@ -398,10 +388,10 @@ func search_3(_ nums: [Int], _ target: Int) -> Bool {
398388
} else if nums.count == 1 {
399389
return nums[0] == target
400390
}
401-
391+
402392
var start = 0
403393
var end = nums.count - 1
404-
394+
405395
while start + 1 < end {
406396
while start + 1 < end {
407397
if nums[start] == nums[start + 1] {
@@ -417,8 +407,8 @@ func search_3(_ nums: [Int], _ target: Int) -> Bool {
417407
break
418408
}
419409
}
420-
421-
410+
411+
422412
let mid = (start + end)/2
423413
if target == nums[mid] {
424414
return true
@@ -445,18 +435,19 @@ func search_3(_ nums: [Int], _ target: Int) -> Bool {
445435

446436
二分搜索核心四点要素(必背&理解)
447437

448-
- 1、初始化:start=0、end=len-1
449-
- 2、循环退出条件:start + 1 < end
450-
- 3、比较中点和目标值:A[mid] ==、 <、> target
451-
- 4、判断最后两个元素是否符合:A[start]、A[end] ? target
438+
* 1、初始化:start=0、end=len-1
439+
* 2、循环退出条件:start + 1 &lt; end
440+
* 3、比较中点和目标值:A\[mid\] ==、 &lt;&gt; target
441+
* 4、判断最后两个元素是否符合:A\[start\]、A\[end\] ? target
452442

453443
## 练习题
454444

455-
- [ ] [search-for-range](https://www.lintcode.com/problem/search-for-a-range/description)
456-
- [ ] [search-insert-position](https://leetcode-cn.com/problems/search-insert-position/)
457-
- [ ] [search-a-2d-matrix](https://leetcode-cn.com/problems/search-a-2d-matrix/)
458-
- [ ] [first-bad-version](https://leetcode-cn.com/problems/first-bad-version/)
459-
- [ ] [find-minimum-in-rotated-sorted-array](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/)
460-
- [ ] [find-minimum-in-rotated-sorted-array-ii](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/)
461-
- [ ] [search-in-rotated-sorted-array](https://leetcode-cn.com/problems/search-in-rotated-sorted-array/)
462-
- [ ] [search-in-rotated-sorted-array-ii](https://leetcode-cn.com/problems/search-in-rotated-sorted-array-ii/)
445+
* [ ] [search-for-range](https://www.lintcode.com/problem/search-for-a-range/description)
446+
* [ ] [search-insert-position](https://leetcode-cn.com/problems/search-insert-position/)
447+
* [ ] [search-a-2d-matrix](https://leetcode-cn.com/problems/search-a-2d-matrix/)
448+
* [ ] [first-bad-version](https://leetcode-cn.com/problems/first-bad-version/)
449+
* [ ] [find-minimum-in-rotated-sorted-array](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/)
450+
* [ ] [find-minimum-in-rotated-sorted-array-ii](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/)
451+
* [ ] [search-in-rotated-sorted-array](https://leetcode-cn.com/problems/search-in-rotated-sorted-array/)
452+
* [ ] [search-in-rotated-sorted-array-ii](https://leetcode-cn.com/problems/search-in-rotated-sorted-array-ii/)
453+

‎basic_algorithm/dp.md renamed to ‎ji-chu-suan-fa-pian/dp.md

Lines changed: 96 additions & 117 deletions
Large diffs are not rendered by default.

‎basic_algorithm/sort.md renamed to ‎ji-chu-suan-fa-pian/sort.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 排序
1+
# 排序算法
22

33
## 常考排序
44

@@ -10,7 +10,7 @@ func QuickSort(_ nums:inout [Int]) -> [Int] {
1010
// 思路:把一个数组分为左右两段,左段小于右段,类似分治法没有合并过程
1111
quickSort(&nums, 0, nums.count - 1)
1212
return nums
13-
13+
1414
}
1515
// 原地交换,所以传入交换索引
1616
func quickSort(_ nums:inout [Int],_ start: Int,_ end: Int) {
@@ -25,14 +25,14 @@ func quickSort(_ nums:inout [Int],_ start: Int,_ end: Int) {
2525
func partition(_ nums:inout [Int],_ start: Int,_ end: Int) -> Int {
2626
let p = nums[end]//参考点。排序:比p小的在左边,比p大的在右边
2727
var i = start
28-
28+
2929
for j in start..<end {
3030
if nums[j] < p {
3131
swap(&nums, i, j)
3232
i += 1
3333
}
3434
}
35-
35+
3636
// 把中间的值换为用于比较的基准值
3737
swap(&nums, i, end)
3838
return i
@@ -48,7 +48,7 @@ func quickSort_a(data:[Int])->[Int]{
4848
if data.count<=1 {
4949
return data
5050
}
51-
51+
5252
var left:[Int] = []
5353
var right:[Int] = []
5454
let pivot:Int = data[data.count-1]
@@ -59,7 +59,7 @@ func quickSort_a(data:[Int])->[Int]{
5959
right.append(data[index])
6060
}
6161
}
62-
62+
6363
var result = quickSort_a(data: left)
6464
result.append(pivot)
6565
let rightResult = quickSort_a(data: right)
@@ -176,7 +176,6 @@ func exchange(_ a: inout [Int], _ i: Int, _ j: Int) {
176176
a[i] = a[j]
177177
a[j] = temp
178178
}
179-
180179
```
181180

182181
## 参考
@@ -187,4 +186,5 @@ func exchange(_ a: inout [Int], _ i: Int, _ j: Int) {
187186

188187
## 练习
189188

190-
- [ ] 手写快排、归并、堆排序
189+
* [ ] 手写快排、归并、堆排序
190+

‎introduction/quickstart.md renamed to ‎ru-men-pian/quickstart.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# 快速开始
1+
# 算法快速入门
22

33
## 数据结构与算法
44

5-
数据结构是一种数据的表现形式,如链表、二叉树、栈、队列等都是内存中一段数据表现的形式。
6-
算法是一种通用的解决问题的模板或者思路,大部分数据结构都有一套通用的算法模板,所以掌握这些通用的算法模板即可解决各种算法问题。
5+
数据结构是一种数据的表现形式,如链表、二叉树、栈、队列等都是内存中一段数据表现的形式。 算法是一种通用的解决问题的模板或者思路,大部分数据结构都有一套通用的算法模板,所以掌握这些通用的算法模板即可解决各种算法问题。
76

87
后面会分专题讲解各种数据结构、基本的算法模板、和一些高级算法模板,每一个专题都有一些经典练习题,完成所有练习的题后,你对数据结构和算法会有新的收获和体会。
98

@@ -13,7 +12,7 @@
1312

1413
[strStr](https://leetcode-cn.com/problems/implement-strstr/)[答案](https://leetcode-cn.com/problems/implement-strstr/solution/yi-ci-bian-li-haystackhaystackcount-needlecountcha/)
1514

16-
> 给定一个  haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从 0 开始)。如果不存在,则返回  -1。
15+
> 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 \(从 0 开始\)。如果不存在,则返回 -1。
1716
1817
思路:核心点遍历给定字符串字符,判断以当前字符开头字符串是否等于目标字符串
1918

@@ -24,22 +23,22 @@ func strStr_c(_ haystack: String, _ needle: String) -> Int {
2423
guard !needle.isEmpty else{
2524
return 0
2625
}
27-
26+
2827
let needleCount = needle.count
2928
let haystackCount = haystack.count
30-
29+
3130
guard needleCount <= haystackCount else{
3231
return -1
3332
}
34-
33+
3534
let iRange = 0...(haystackCount - needleCount)
36-
35+
3736
for i in iRange {
3837
let startIndex = haystack.index(haystack.startIndex, offsetBy: i)
3938
let endIndex = haystack.index(startIndex, offsetBy: needleCount)
4039
let haystackRange = haystack[startIndex..<endIndex]
41-
42-
40+
41+
4342
if haystackRange == needle {
4443
return i
4544
}else{
@@ -52,9 +51,7 @@ func strStr_c(_ haystack: String, _ needle: String) -> Int {
5251

5352
需要注意点
5453

55-
- 循环时,i 的范围只要`0...(haystackCount - needleCount)`
56-
57-
54+
* 循环时,i 的范围只要`0...(haystackCount - needleCount)`
5855

5956
示例 2
6057

@@ -86,7 +83,7 @@ func backtrack(选择列表,路径):
8683
//内存消耗:13.5 MB, 在所有 Swift 提交中击败了93.90%的用户
8784
func subsets(_ nums: [Int]) -> [[Int]] {
8885
var res = [[Int]]()
89-
86+
9087
func backtrack(start :Int, track: inout [Int]){
9188
res.append(track)
9289
for index in start..<nums.count {
@@ -95,10 +92,10 @@ func subsets(_ nums: [Int]) -> [[Int]] {
9592
track.popLast()
9693
}
9794
}
98-
95+
9996
var items = [Int]()
10097
backtrack(start: 0, track: &items)
101-
98+
10299
return res
103100
}
104101
```
@@ -109,15 +106,16 @@ func subsets(_ nums: [Int]) -> [[Int]] {
109106

110107
我们大多数时候,刷算法题可能都是为了准备面试,所以面试的时候需要注意一些点
111108

112-
- 快速定位到题目的知识点,找到知识点的**通用模板**,可能需要根据题目**特殊情况做特殊处理**
113-
- 先去朝一个解决问题的方向!**先抛出可行解**,而不是最优解!先解决,再优化!
114-
- 代码的风格要统一,熟悉各类语言的代码规范。
115-
- 命名尽量简洁明了,尽量不用数字命名如:i1、node1、a1、b2
116-
- 常见错误总结
117-
- 访问下标时,不能访问越界
118-
- 空值 nil 问题 run time error
109+
* 快速定位到题目的知识点,找到知识点的**通用模板**,可能需要根据题目**特殊情况做特殊处理**
110+
* 先去朝一个解决问题的方向!**先抛出可行解**,而不是最优解!先解决,再优化!
111+
* 代码的风格要统一,熟悉各类语言的代码规范。
112+
* 命名尽量简洁明了,尽量不用数字命名如:i1、node1、a1、b2
113+
* 常见错误总结
114+
* 访问下标时,不能访问越界
115+
* 空值 nil 问题 run time error
119116

120117
## 练习
121118

122-
- [ ] [strStr](https://leetcode-cn.com/problems/implement-strstr/)
123-
- [ ] [subsets](https://leetcode-cn.com/problems/subsets/)
119+
* [ ] [strStr](https://leetcode-cn.com/problems/implement-strstr/)
120+
* [ ] [subsets](https://leetcode-cn.com/problems/subsets/)
121+

‎introduction/swift.md renamed to ‎ru-men-pian/swift.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Swift 快速入门
1+
# swift 语言入门
22

33
## 基本语法
44

@@ -8,12 +8,13 @@
88

99
### 数组
1010

11-
Swift语言中没有内设的栈和队列, 可通过数组或链表模拟栈和队列(链表的加入和删除的时间复杂度是O(1),但因为Swift没有现成的链表,而数组又有很多的API可以直接使用,所以下面用数组实现)
11+
Swift语言中没有内设的栈和队列, 可通过数组或链表模拟栈和队列(链表的加入和删除的时间复杂度是O\(1\),但因为Swift没有现成的链表,而数组又有很多的API可以直接使用,所以下面用数组实现)
1212

1313
####
14-
- 栈是后进先出的结构。你可以理解成有好几个盘子要垒成一叠,哪个盘子最后叠上去,下次使用的时候它就最先被抽出去
15-
- 在iOS开发中,如果你要在你的App中添加撤销操作(比如删除图片,恢复删除图片),那么栈是首选数据结构
16-
- 几个基本操作:push、pop、isEmpty、peek、size
14+
15+
* 栈是后进先出的结构。你可以理解成有好几个盘子要垒成一叠,哪个盘子最后叠上去,下次使用的时候它就最先被抽出去
16+
* 在iOS开发中,如果你要在你的App中添加撤销操作(比如删除图片,恢复删除图片),那么栈是首选数据结构
17+
* 几个基本操作:push、pop、isEmpty、peek、size
1718

1819
```swift
1920
///
@@ -25,17 +26,17 @@ class Stack<Element> {
2526
var peek: Element? { return stack.last }
2627
/// 栈大小
2728
var size: Int { return stack.count }
28-
29+
2930
init() {
3031
stack = [Element]()
3132
}
32-
33+
3334
/// push压入
3435
/// - Parameter object: 元素
3536
func push(object: Element) {
3637
stack.append(object)
3738
}
38-
39+
3940
/// pop弹出
4041
/// - Returns: 元素
4142
func pop() -> Element? {
@@ -45,9 +46,10 @@ class Stack<Element> {
4546
```
4647

4748
#### 队列
48-
- 队列是先进先出的结构。这个正好就像现实生活中排队买票,谁先来排队,谁先买到票
49-
- iOS开发中多线程的GCD和NSOperationQueue就是基于队列实现的
50-
- 几个基本操作:enqueue、dequeue、isEmpty、peek、size
49+
50+
* 队列是先进先出的结构。这个正好就像现实生活中排队买票,谁先来排队,谁先买到票
51+
* iOS开发中多线程的GCD和NSOperationQueue就是基于队列实现的
52+
* 几个基本操作:enqueue、dequeue、isEmpty、peek、size
5153

5254
```swift
5355
/// 队列
@@ -60,26 +62,26 @@ class Queue<Element> {
6062
var size: Int { return left.count + right.count }
6163
/// 队列顶元素
6264
var peek: Element? { return left.isEmpty ? right.first : left.last }
63-
65+
6466
init() {
6567
left = [Element]()
6668
right = [Element]()
6769
}
68-
70+
6971
/// 入队
7072
/// - Parameter object: 元素
7173
func enqueue(object: Element) {
7274
right.append(object)
7375
}
74-
76+
7577
/// 出队
7678
/// - Returns: 元素
7779
func dequeue() -> Element? {
7880
if left.isEmpty {
7981
left = right.reversed()
8082
right.removeAll()
8183
}
82-
84+
8385
return left.popLast()
8486
}
8587
}
@@ -110,26 +112,22 @@ for (k, v) in m {
110112

111113
注意点
112114

113-
- 一个字典的 Key 类型必须遵循 Hashable 协议
114-
115+
* 一个字典的 Key 类型必须遵循 Hashable 协议
115116

116117
### 标准库
117118

118119
#### sort、sorted
119120

120121
区别:
121122

122-
- sort()方法直接改变当前数组。
123-
- sorted()方法返回一个当前数组的 copy 排序后返回。
123+
* sort\(\)方法直接改变当前数组。
124+
* sorted\(\)方法返回一个当前数组的 copy 排序后返回。
124125

125126
注意:
126127

127-
- 选择使用哪一个方法,要看具体的使用环境,如果不想改变数组而只是单纯的想获取排序后的结果,则应该使用sorted() 。
128-
129-
- 如果想要改变数组,应当注意如果该数组是函数的参数,Swift 的函数的参数默认是常量类型,想要改变必须加入inout修饰。
130-
131-
- sorted()是值类型拷贝,如果数组太大,会消耗太多内存。
132-
128+
* 选择使用哪一个方法,要看具体的使用环境,如果不想改变数组而只是单纯的想获取排序后的结果,则应该使用sorted\(\)
129+
* 如果想要改变数组,应当注意如果该数组是函数的参数,Swift 的函数的参数默认是常量类型,想要改变必须加入inout修饰。
130+
* sorted\(\)是值类型拷贝,如果数组太大,会消耗太多内存。
133131

134132
```swift
135133
let numbers = [12,25,1,35,27]
@@ -139,7 +137,7 @@ let numbersSorted = numbers.sorted{ (n1:Int, n2:Int) -> Bool in
139137
print(numbersSorted)//[1, 12, 25, 27, 35]
140138
```
141139

142-
143140
## 刷题注意点
144141

145-
- leetcode 中,全局变量不要当做返回值,否则刷题检查器会报错
142+
* leetcode 中,全局变量不要当做返回值,否则刷题检查器会报错
143+

‎data_structure/binary_op.md renamed to ‎shu-ju-jie-gou-pian/binary_op.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ a=a^b
2020

2121
### 移除最后一个 1
2222

23-
a=n&(n-1)
23+
a=n&\(n-1\)
2424

2525
### 获取最后一个 1
2626

27-
diff=(n&(n-1))^n
27+
diff=\(n&\(n-1\)\)^n
2828

2929
## 常见题目
3030

@@ -61,7 +61,6 @@ func singleNumber(_ nums: [Int]) -> Int {
6161
>
6262
> 3)某数第三次出现,本来要存于once,结果twice中存在,所以,清零
6363
64-
6564
```swift
6665
//https://leetcode-cn.com/problems/single-number-ii/solution/swift-wei-yun-suan-by-hu-cheng-he-da-bai-sha-2/
6766
//思路:https://leetcode-cn.com/problems/single-number-ii/solution/single-number-ii-mo-ni-san-jin-zhi-fa-by-jin407891/
@@ -79,7 +78,7 @@ func singleNumber_1(_ nums: [Int]) -> Int {
7978

8079
[single-number-iii](https://leetcode-cn.com/problems/single-number-iii/)
8180

82-
> 给定一个整数数组  `nums`,其中恰好有两个元素只出现一次,其余所有元素均出现两次。 找出只出现一次的那两个元素。
81+
> 给定一个整数数组 `nums`,其中恰好有两个元素只出现一次,其余所有元素均出现两次。 找出只出现一次的那两个元素。
8382
8483
```swift
8584
//https://leetcode-cn.com/problems/single-number-iii/solution/swift-fen-liang-zu-lai-jiang-wei-dao-qiu-chu-xian-/
@@ -111,7 +110,7 @@ func singleNumber(_ nums: [Int]) -> [Int] {
111110

112111
[number-of-1-bits](https://leetcode-cn.com/problems/number-of-1-bits/)
113112

114-
> 编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 ‘1’  的个数(也被称为[汉明重量](https://baike.baidu.com/item/%E6%B1%89%E6%98%8E%E9%87%8D%E9%87%8F))。
113+
> 编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 ‘1’ 的个数(也被称为[汉明重量](https://baike.baidu.com/item/%E6%B1%89%E6%98%8E%E9%87%8D%E9%87%8F))。
115114
116115
在二进制表示中,数字 n 中最低位的 1总是对应 n - 1中的 0 。因此,将 n 和 n - 1与运算总是能把 n中最低位的 1 变成 0 ,并保持其他位不变。
117116

@@ -132,7 +131,7 @@ func hammingWeight(_ n: Int) -> Int {
132131

133132
[counting-bits](https://leetcode-cn.com/problems/counting-bits/)
134133

135-
> 给定一个非负整数  **num**。对于  0 ≤ i ≤ num  范围中的每个数字  i ,计算其二进制数中的 1 的数目并将它们作为数组返回。
134+
> 给定一个非负整数 **num**。对于 0 ≤ i ≤ num 范围中的每个数字 i ,计算其二进制数中的 1 的数目并将它们作为数组返回。
136135
137136
```swift
138137
//https://leetcode-cn.com/problems/counting-bits/solution/swift-bian-li-mei-ge-shu-an-191-wei-1de-ge-shu-qiu/
@@ -199,7 +198,7 @@ func reverseBits(_ n: Int) -> Int {
199198
while num != 0 {
200199
let bit = num&1
201200
res += bit << pow
202-
201+
203202
num = num >> 1
204203
pow -= 1
205204
}
@@ -209,7 +208,7 @@ func reverseBits(_ n: Int) -> Int {
209208

210209
[bitwise-and-of-numbers-range](https://leetcode-cn.com/problems/bitwise-and-of-numbers-range/)
211210

212-
> 给定范围 [m, n],其中 0 <= m <= n <= 2147483647,返回此范围内所有数字的按位与(包含 m, n 两端点)。
211+
> 给定范围 \[m, n\],其中 0 &lt;= m &lt;= n &lt;= 2147483647,返回此范围内所有数字的按位与(包含 m, n 两端点)。
213212
214213
```swift
215214
//https://leetcode-cn.com/problems/bitwise-and-of-numbers-range/solution/swift-zui-zhong-jie-guo-you-zuo-bian-gong-gong-zhi/
@@ -236,11 +235,11 @@ func rangeBitwiseAnd(_ m: Int, _ n: Int) -> Int {
236235

237236
## 练习
238237

239-
- [ ] [single-number](https://leetcode-cn.com/problems/single-number/)
240-
- [ ] [single-number-ii](https://leetcode-cn.com/problems/single-number-ii/)
241-
- [ ] [single-number-iii](https://leetcode-cn.com/problems/single-number-iii/)
242-
- [ ] [number-of-1-bits](https://leetcode-cn.com/problems/number-of-1-bits/)
243-
- [ ] [counting-bits](https://leetcode-cn.com/problems/counting-bits/)
244-
- [ ] [reverse-bits](https://leetcode-cn.com/problems/reverse-bits/)
245-
- [ ] [bitwise-and-of-numbers-range](https://leetcode-cn.com/problems/bitwise-and-of-numbers-range/)
238+
* [ ] [single-number](https://leetcode-cn.com/problems/single-number/)
239+
* [ ] [single-number-ii](https://leetcode-cn.com/problems/single-number-ii/)
240+
* [ ] [single-number-iii](https://leetcode-cn.com/problems/single-number-iii/)
241+
* [ ] [number-of-1-bits](https://leetcode-cn.com/problems/number-of-1-bits/)
242+
* [ ] [counting-bits](https://leetcode-cn.com/problems/counting-bits/)
243+
* [ ] [reverse-bits](https://leetcode-cn.com/problems/reverse-bits/)
244+
* [ ] [bitwise-and-of-numbers-range](https://leetcode-cn.com/problems/bitwise-and-of-numbers-range/)
246245

‎data_structure/binary_tree.md renamed to ‎shu-ju-jie-gou-pian/binary_tree.md

Lines changed: 89 additions & 93 deletions
Large diffs are not rendered by default.

‎data_structure/linked_list.md renamed to ‎shu-ju-jie-gou-pian/linked_list.md

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
链表相关的核心点
66

7-
- null/nil 异常处理
8-
- dummy node 哑巴节点
9-
- 快慢指针
10-
- 插入一个节点到排序链表
11-
- 从一个链表中移除一个节点
12-
- 翻转链表
13-
- 合并两个链表
14-
- 找到链表的中间节点
7+
* null/nil 异常处理
8+
* dummy node 哑巴节点
9+
* 快慢指针
10+
* 插入一个节点到排序链表
11+
* 从一个链表中移除一个节点
12+
* 翻转链表
13+
* 合并两个链表
14+
* 找到链表的中间节点
1515

1616
## 常见题型
1717

@@ -47,7 +47,7 @@ class Solution {
4747

4848
### [remove-duplicates-from-sorted-list-ii](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/)
4949

50-
> 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中   没有重复出现的数字。
50+
> 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现的数字。
5151
5252
思路:链表头结点可能被删除,所以用 dummy node 辅助删除
5353

@@ -108,10 +108,7 @@ class Solution {
108108
}
109109
```
110110

111-
注意点
112-
• A->B->C 删除 B,A.next = C
113-
• 删除用一个 Dummy Node 节点辅助(允许头节点可变)
114-
• 访问 X.next 、X.value 一定要保证 X != nil
111+
注意点 • A-&gt;B-&gt;C 删除 B,A.next = C • 删除用一个 Dummy Node 节点辅助(允许头节点可变) • 访问 X.next 、X.value 一定要保证 X != nil
115112

116113
### [reverse-linked-list](https://leetcode-cn.com/problems/reverse-linked-list/)
117114

@@ -153,7 +150,7 @@ func reverseList(_ head: ListNode?) -> ListNode? {
153150

154151
### [reverse-linked-list-ii](https://leetcode-cn.com/problems/reverse-linked-list-ii/)
155152

156-
> 反转从位置  *m*  *n*  的链表。请使用一趟扫描完成反转。
153+
> 反转从位置 _m__n_ 的链表。请使用一趟扫描完成反转。
157154
158155
思路:先遍历到 m 处,翻转,再拼接后续,注意指针处理
159156

@@ -250,7 +247,7 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
250247

251248
### [partition-list](https://leetcode-cn.com/problems/partition-list/)
252249

253-
> 给定一个链表和一个特定值 x,对链表进行分隔,使得所有小于  *x*  的节点都在大于或等于  *x*  的节点之前。
250+
> 给定一个链表和一个特定值 x,对链表进行分隔,使得所有小于 _x_ 的节点都在大于或等于 _x_ 的节点之前。
254251
255252
思路:将大于 x 的节点,放到另外一个链表,最后连接这两个链表
256253

@@ -291,7 +288,7 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
291288
292289
### [sort-list](https://leetcode-cn.com/problems/sort-list/)
293290

294-
>  *O*(*n* log *n*) 时间复杂度和常数级空间复杂度下,对链表进行排序。
291+
> _O_\(_n_ log _n_\) 时间复杂度和常数级空间复杂度下,对链表进行排序。
295292
296293
思路:归并排序,找中点和合并操作
297294

@@ -368,12 +365,11 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
368365

369366
注意点
370367

371-
- 链表的递归函数调用空间复杂度:O(logn),所以必须使用非递归
368+
* 链表的递归函数调用空间复杂度:O\(logn\),所以必须使用非递归
372369

373370
### [reorder-list](https://leetcode-cn.com/problems/reorder-list/)
374371

375-
> 给定一个单链表  *L**L**L*→…→*L\_\_n**L*
376-
> 将其重新排列后变为: *L**L\_\_n**L**L\_\_n**L**L\_\_n*→…
372+
> 给定一个单链表 _L__L__L_→…→_L\_\_n__L_ 将其重新排列后变为: _L__L\_\_n__L__L\_\_n__L__L\_\_n_→…
377373
378374
思路:找到中点断开,翻转后面部分,然后合并前后两个链表
379375

@@ -432,8 +428,7 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
432428

433429
> 给定一个链表,判断链表中是否有环。
434430
435-
思路:快慢指针,快慢指针相同则有环,证明:如果有环每走一步快慢指针距离会减 1
436-
![fast_slow_linked_list](https://img.fuiboom.com/img/fast_slow_linked_list.png)
431+
思路:快慢指针,快慢指针相同则有环,证明:如果有环每走一步快慢指针距离会减 1 ![fast\_slow\_linked\_list](https://img.fuiboom.com/img/fast_slow_linked_list.png)
437432

438433
```swift
439434
//https://leetcode-cn.com/problems/linked-list-cycle/solution/swift-kuai-man-zhi-zhen-huan-lu-jian-ce-kong-jian-/
@@ -459,10 +454,9 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
459454

460455
### [linked-list-cycle-ii](https://leetcode-cn.com/problems/linked-list-cycle-ii/)
461456

462-
> 给定一个链表,返回链表开始入环的第一个节点。  如果链表无环,则返回  `null`
457+
> 给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回 `null`
463458
464-
思路:快慢指针,快慢相遇之后,慢指针回到头,快慢指针步调一致一起移动,相遇点即为入环点
465-
![cycled_linked_list](https://img.fuiboom.com/img/cycled_linked_list.png)
459+
思路:快慢指针,快慢相遇之后,慢指针回到头,快慢指针步调一致一起移动,相遇点即为入环点 ![cycled\_linked\_list](https://img.fuiboom.com/img/cycled_linked_list.png)
466460

467461
```swift
468462
//https://leetcode-cn.com/problems/linked-list-cycle-ii/solution/swift-kuai-man-zhi-zhen-kuai-man-xiang-yu-zhi-hou-/
@@ -537,8 +531,7 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
537531

538532
### [copy-list-with-random-pointer](https://leetcode-cn.com/problems/copy-list-with-random-pointer/)
539533

540-
> 给定一个链表,每个节点包含一个额外增加的随机指针,该指针可以指向链表中的任何节点或空节点。
541-
> 要求返回这个链表的 深拷贝。
534+
> 给定一个链表,每个节点包含一个额外增加的随机指针,该指针可以指向链表中的任何节点或空节点。 要求返回这个链表的 深拷贝。
542535
543536
思路:1、hash 表存储指针,2、递归, 3、复制节点跟在原节点后面
544537

@@ -562,7 +555,7 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
562555
visited[key] = new
563556
return new
564557
}
565-
558+
566559
var oldCur = head
567560
var newCur: Node?
568561
while let old = oldCur {
@@ -575,7 +568,7 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
575568
}
576569
return clonedNode(head)
577570
}
578-
571+
579572
//https://leetcode-cn.com/problems/copy-list-with-random-pointer/solution/swift-shen-du-bian-li-di-gui-shi-xian-by-hu-cheng-/
580573
//深度遍历递归实现
581574
//执行用时:48 ms, 在所有 Swift 提交中击败了90.16%的用户
@@ -585,7 +578,7 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
585578
guard let from = head else {
586579
return nil
587580
}
588-
581+
589582
let key = Unmanaged.passUnretained(from).toOpaque()
590583
if let item = visited[key]{
591584
return item
@@ -598,7 +591,7 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
598591

599592
return copedItem
600593
}
601-
594+
602595
//https://leetcode-cn.com/problems/copy-list-with-random-pointer/solution/swift-fu-zhi-jie-dian-gen-zai-yuan-jie-dian-hou-mi/
603596
//swift 复制节点跟在原节点后面(空间O(1))
604597
//执行用时:48 ms, 在所有 Swift 提交中击败了90.16%的用户
@@ -607,33 +600,33 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
607600
guard head != nil else {
608601
return nil
609602
}
610-
603+
611604
var cur = head
612605
while let old = cur {
613606
let copied = Node(old.val)
614607
copied.next = old.next
615608
old.next = copied
616609
cur = copied.next
617610
}
618-
611+
619612
cur = head
620613
while let old = cur {
621614
old.next?.random = old.random?.next
622615
cur = old.next?.next
623616
}
624-
617+
625618
cur = head
626619
let copiedList = head!.next
627620
var pre: Node? = nil
628621
while let old = cur {
629622
pre?.next = old.next
630623
pre = old.next
631-
624+
632625
old.next = old.next?.next
633-
626+
634627
cur = old.next
635628
}
636-
629+
637630
return copiedList
638631
}
639632
```
@@ -642,26 +635,27 @@ func reverseBetween(_ head: ListNode?, _ m: Int, _ n: Int) -> ListNode? {
642635

643636
链表必须要掌握的一些点,通过下面练习题,基本大部分的链表类的题目都是手到擒来~
644637

645-
- null/nil 异常处理
646-
- dummy node 哑巴节点
647-
- 快慢指针
648-
- 插入一个节点到排序链表
649-
- 从一个链表中移除一个节点
650-
- 翻转链表
651-
- 合并两个链表
652-
- 找到链表的中间节点
638+
* null/nil 异常处理
639+
* dummy node 哑巴节点
640+
* 快慢指针
641+
* 插入一个节点到排序链表
642+
* 从一个链表中移除一个节点
643+
* 翻转链表
644+
* 合并两个链表
645+
* 找到链表的中间节点
653646

654647
## 练习
655648

656-
- [ ] [remove-duplicates-from-sorted-list](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/)
657-
- [ ] [remove-duplicates-from-sorted-list-ii](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/)
658-
- [ ] [reverse-linked-list](https://leetcode-cn.com/problems/reverse-linked-list/)
659-
- [ ] [reverse-linked-list-ii](https://leetcode-cn.com/problems/reverse-linked-list-ii/)
660-
- [ ] [merge-two-sorted-lists](https://leetcode-cn.com/problems/merge-two-sorted-lists/)
661-
- [ ] [partition-list](https://leetcode-cn.com/problems/partition-list/)
662-
- [ ] [sort-list](https://leetcode-cn.com/problems/sort-list/)
663-
- [ ] [reorder-list](https://leetcode-cn.com/problems/reorder-list/)
664-
- [ ] [linked-list-cycle](https://leetcode-cn.com/problems/linked-list-cycle/)
665-
- [ ] [linked-list-cycle-ii](https://leetcode-cn.com/problems/linked-list-cycle-ii/)
666-
- [ ] [palindrome-linked-list](https://leetcode-cn.com/problems/palindrome-linked-list/)
667-
- [ ] [copy-list-with-random-pointer](https://leetcode-cn.com/problems/copy-list-with-random-pointer/)
649+
* [ ] [remove-duplicates-from-sorted-list](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/)
650+
* [ ] [remove-duplicates-from-sorted-list-ii](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/)
651+
* [ ] [reverse-linked-list](https://leetcode-cn.com/problems/reverse-linked-list/)
652+
* [ ] [reverse-linked-list-ii](https://leetcode-cn.com/problems/reverse-linked-list-ii/)
653+
* [ ] [merge-two-sorted-lists](https://leetcode-cn.com/problems/merge-two-sorted-lists/)
654+
* [ ] [partition-list](https://leetcode-cn.com/problems/partition-list/)
655+
* [ ] [sort-list](https://leetcode-cn.com/problems/sort-list/)
656+
* [ ] [reorder-list](https://leetcode-cn.com/problems/reorder-list/)
657+
* [ ] [linked-list-cycle](https://leetcode-cn.com/problems/linked-list-cycle/)
658+
* [ ] [linked-list-cycle-ii](https://leetcode-cn.com/problems/linked-list-cycle-ii/)
659+
* [ ] [palindrome-linked-list](https://leetcode-cn.com/problems/palindrome-linked-list/)
660+
* [ ] [copy-list-with-random-pointer](https://leetcode-cn.com/problems/copy-list-with-random-pointer/)
661+

‎data_structure/stack_queue.md renamed to ‎shu-ju-jie-gou-pian/stack_queue.md

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ stack.getMin()
6767

6868
[evaluate-reverse-polish-notation](https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/)
6969

70-
> **波兰表达式计算** > **输入:** ["2", "1", "+", "3", "*"] > **输出:** 9
71-
> **解释:** ((2 + 1) \* 3) = 9
70+
> **波兰表达式计算** &gt; **输入:** \["2", "1", "+", "3", "_"\] &gt; **输出:** 9 **解释:** \(\(2 + 1\) \_ 3\) = 9
7271
7372
思路:通过栈保存原来的元素,遇到表达式弹出运算,再推入结果,重复这个过程
7473

@@ -105,10 +104,7 @@ stack.getMin()
105104

106105
[decode-string](https://leetcode-cn.com/problems/decode-string/)
107106

108-
> 给定一个经过编码的字符串,返回它解码后的字符串。
109-
> s = "3[a]2[bc]", 返回 "aaabcbc".
110-
> s = "3[a2[c]]", 返回 "accaccacc".
111-
> s = "2[abc]3[cd]ef", 返回 "abcabccdcdcdef".
107+
> 给定一个经过编码的字符串,返回它解码后的字符串。 s = "3\[a\]2\[bc\]", 返回 "aaabcbc". s = "3\[a2\[c\]\]", 返回 "accaccacc". s = "2\[abc\]3\[cd\]ef", 返回 "abcabccdcdcdef".
112108
113109
思路:通过栈辅助进行操作
114110

@@ -157,7 +153,7 @@ func decodeString(s string) string {
157153

158154
[binary-tree-inorder-traversal](https://leetcode-cn.com/problems/binary-tree-inorder-traversal/)
159155

160-
> 给定一个二叉树,返回它的*中序*遍历
156+
> 给定一个二叉树,返回它的_中序_遍历
161157
162158
```swift
163159
// 思路:通过stack 保存已经访问的元素,用于原路返回
@@ -177,7 +173,7 @@ func decodeString(s string) string {
177173
}
178174
return res
179175
}
180-
176+
181177
//ps:递归实现 https://leetcode-cn.com/problems/binary-tree-inorder-traversal/solution/di-gui-by-hu-cheng-he-da-bai-sha-2/
182178
```
183179

@@ -195,35 +191,35 @@ func decodeString(s string) string {
195191
self.neighbors = []
196192
}
197193
}
198-
194+
199195
func cloneGraph(_ node: Node?) -> Node? {
200196
var visited = [Int : Node?]()
201197
func dfs(_ node: Node?) -> Node?{
202198
guard let current = node else{
203199
return nil
204200
}
205-
201+
206202
if let visitedItem = visited[current.val]{
207203
return visitedItem
208204
}
209-
205+
210206
let clonedNode = Node(current.val)
211207
visited[clonedNode.val] = clonedNode
212-
208+
213209
for neighbor in current.neighbors {
214210
clonedNode.neighbors.append(dfs(neighbor))
215211
}
216-
212+
217213
return clonedNode
218214
}
219-
215+
220216
return dfs(node)
221217
}
222218
```
223219

224220
[number-of-islands](https://leetcode-cn.com/problems/number-of-islands/)
225221

226-
> 给定一个由  '1'(陆地)和 '0'(水)组成的的二维网格,计算岛屿的数量。一个岛被水包围,并且它是通过水平方向或垂直方向上相邻的陆地连接而成的。你可以假设网格的四个边均被水包围。
222+
> 给定一个由 '1'(陆地)和 '0'(水)组成的的二维网格,计算岛屿的数量。一个岛被水包围,并且它是通过水平方向或垂直方向上相邻的陆地连接而成的。你可以假设网格的四个边均被水包围。
227223
228224
思路:通过深度搜索遍历可能性(注意标记已访问元素)
229225

@@ -236,7 +232,7 @@ func decodeString(s string) string {
236232
return 0
237233
}
238234
let cn = copydGrid[0].count
239-
235+
240236
func dfs(_ r: Int,_ c:Int) {
241237
guard r >= 0 && r < rn && c >= 0 && c < cn && copydGrid[r][c] == "1" else{
242238
return
@@ -247,7 +243,7 @@ func decodeString(s string) string {
247243
dfs(r, c-1)//
248244
dfs(r, c+1)//
249245
}
250-
246+
251247
var islandCount = 0
252248
for r in 0..<rn {
253249
for c in 0..<cn {
@@ -263,9 +259,7 @@ func decodeString(s string) string {
263259

264260
[largest-rectangle-in-histogram](https://leetcode-cn.com/problems/largest-rectangle-in-histogram/)
265261

266-
> 给定 _n_ 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。
267-
> 求在该柱状图中,能够勾勒出来的矩形的最大面积。
268-
262+
> 给定 _n_ 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。 求在该柱状图中,能够勾勒出来的矩形的最大面积。
269263
270264
```swift
271265
//单调栈
@@ -289,7 +283,7 @@ func decodeString(s string) string {
289283
}
290284
stack.append(i)
291285
}
292-
286+
293287
//遍历完后需要处理栈中剩余元素
294288
while !stack.isEmpty {
295289
let highest = heights[stack.popLast()!]
@@ -300,7 +294,7 @@ func decodeString(s string) string {
300294
let width = stack.isEmpty ? nums : (nums - stack.last! - 1)//栈为空的特殊情况处理
301295
maxArea = max(maxArea,highest * width)
302296
}
303-
297+
304298
return maxArea
305299
}
306300
```
@@ -314,10 +308,10 @@ func decodeString(s string) string {
314308
if heights.count == 0 {
315309
return 0
316310
}
317-
311+
318312
let heights = [0] + heights + [0]
319313
let nums = heights.count
320-
314+
321315
var stack = [Int]()
322316
stack.append(heights[0])
323317

@@ -356,17 +350,17 @@ class Stack<Element> {
356350
var peek: Element? { return stack.last }
357351
/// 栈大小
358352
var size: Int { return stack.count }
359-
353+
360354
init() {
361355
stack = [Element]()
362356
}
363-
357+
364358
/// push压入
365359
/// - Parameter object: 元素
366360
func push(object: Element) {
367361
stack.append(object)
368362
}
369-
363+
370364
/// pop弹出
371365
/// - Returns: 元素
372366
func pop() -> Element? {
@@ -384,44 +378,43 @@ class MyQueue {
384378
rightStack = Stack()
385379

386380
}
387-
381+
388382
/** Push element x to the back of queue. */
389383
func push(_ x: Int) {
390384
rightStack.push(object: x)
391385
}
392-
386+
393387
/** Removes the element from in front of queue and returns that element. */
394388
func pop() -> Int {
395389
self.checkLeftStack()
396390
return leftStack.pop()!
397391
}
398-
392+
399393
/** Get the front element. */
400394
func peek() -> Int {
401395
self.checkLeftStack()
402396
return leftStack.peek!
403397
}
404-
398+
405399
/** Returns whether the queue is empty. */
406400
func empty() -> Bool {
407401
return leftStack.isEmpty && rightStack.isEmpty
408402
}
409-
403+
410404
private func checkLeftStack(){
411405
if leftStack.isEmpty {
412406
while !rightStack.isEmpty {
413407
leftStack.push(object: rightStack.pop()!)
414408
}
415-
409+
416410
}
417411
}
418412
}
419413
```
420414

421415
[01-matrix](https://leetcode-cn.com/problems/01-matrix/)
422416

423-
> 给定一个由 0 和 1 组成的矩阵,找出每个元素到最近的 0 的距离。
424-
> 两个相邻元素间的距离为 1
417+
> 给定一个由 0 和 1 组成的矩阵,找出每个元素到最近的 0 的距离。 两个相邻元素间的距离为 1
425418
426419
```swift
427420
//https://leetcode-cn.com/problems/01-matrix/solution/swift-yan-du-bian-li-by-hu-cheng-he-da-bai-sha/
@@ -453,7 +446,7 @@ class MyQueue {
453446
}else{
454447
res[x][y] = -1
455448
}
456-
449+
457450
}
458451
}
459452
while !queue.isEmpty {
@@ -472,24 +465,26 @@ class MyQueue {
472465

473466
//动态规划解题:https://leetcode-cn.com/problems/01-matrix/solution/swift-dong-tai-gui-hua-by-hu-cheng-he-da-bai-sha/
474467
```
468+
475469
相似题目:[1162. 地图分析](https://leetcode-cn.com/problems/as-far-from-land-as-possible/)
476470

477471
## 总结
478472

479-
- 熟悉栈的使用场景
480-
- 后入先出,保存临时值
481-
- 利用栈 DFS 深度搜索
482-
- 熟悉队列的使用场景
483-
- 利用队列 BFS 广度搜索
473+
* 熟悉栈的使用场景
474+
* 后入先出,保存临时值
475+
* 利用栈 DFS 深度搜索
476+
* 熟悉队列的使用场景
477+
* 利用队列 BFS 广度搜索
484478

485479
## 练习
486480

487-
- [ ] [min-stack](https://leetcode-cn.com/problems/min-stack/)
488-
- [ ] [evaluate-reverse-polish-notation](https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/)
489-
- [ ] [decode-string](https://leetcode-cn.com/problems/decode-string/)
490-
- [ ] [binary-tree-inorder-traversal](https://leetcode-cn.com/problems/binary-tree-inorder-traversal/)
491-
- [ ] [clone-graph](https://leetcode-cn.com/problems/clone-graph/)
492-
- [ ] [number-of-islands](https://leetcode-cn.com/problems/number-of-islands/)
493-
- [ ] [largest-rectangle-in-histogram](https://leetcode-cn.com/problems/largest-rectangle-in-histogram/)
494-
- [ ] [implement-queue-using-stacks](https://leetcode-cn.com/problems/implement-queue-using-stacks/)
495-
- [ ] [01-matrix](https://leetcode-cn.com/problems/01-matrix/)
481+
* [ ] [min-stack](https://leetcode-cn.com/problems/min-stack/)
482+
* [ ] [evaluate-reverse-polish-notation](https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/)
483+
* [ ] [decode-string](https://leetcode-cn.com/problems/decode-string/)
484+
* [ ] [binary-tree-inorder-traversal](https://leetcode-cn.com/problems/binary-tree-inorder-traversal/)
485+
* [ ] [clone-graph](https://leetcode-cn.com/problems/clone-graph/)
486+
* [ ] [number-of-islands](https://leetcode-cn.com/problems/number-of-islands/)
487+
* [ ] [largest-rectangle-in-histogram](https://leetcode-cn.com/problems/largest-rectangle-in-histogram/)
488+
* [ ] [implement-queue-using-stacks](https://leetcode-cn.com/problems/implement-queue-using-stacks/)
489+
* [ ] [01-matrix](https://leetcode-cn.com/problems/01-matrix/)
490+

‎advanced_algorithm/backtrack.md renamed to ‎suan-fa-si-wei/backtrack.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 背景
44

5-
回溯法(backtrack)常用于遍历列表所有子集,是 DFS 深度搜索一种,一般用于全排列,穷尽所有可能,遍历的过程实际上是一个决策树的遍历过程。时间复杂度一般 O(N!),它不像动态规划存在重叠子问题可以优化,回溯算法就是纯暴力穷举,复杂度一般都很高。
5+
回溯法(backtrack)常用于遍历列表所有子集,是 DFS 深度搜索一种,一般用于全排列,穷尽所有可能,遍历的过程实际上是一个决策树的遍历过程。时间复杂度一般 O\(N!\),它不像动态规划存在重叠子问题可以优化,回溯算法就是纯暴力穷举,复杂度一般都很高。
66

77
## 模板
88

@@ -37,7 +37,7 @@ func backtrack(选择列表,路径):
3737
//内存消耗:13.5 MB, 在所有 Swift 提交中击败了93.90%的用户
3838
func subsets(_ nums: [Int]) -> [[Int]] {
3939
var res = [[Int]]()
40-
40+
4141
func backtrack(start :Int, track: inout [Int]){
4242
res.append(track)
4343
for index in start..<nums.count {
@@ -46,10 +46,10 @@ func subsets(_ nums: [Int]) -> [[Int]] {
4646
track.popLast()
4747
}
4848
}
49-
49+
5050
var items = [Int]()
5151
backtrack(start: 0, track: &items)
52-
52+
5353
return res
5454
}
5555

@@ -60,15 +60,15 @@ func subsets(_ nums: [Int]) -> [[Int]] {
6060
func subsets_a(_ nums: [Int]) -> [[Int]] {
6161
var res = [[Int]]()
6262
res.append([Int]())
63-
63+
6464
for num in nums {
6565
var list = [[Int]]()
6666
for item in res {
6767
list.append(item + [num])
6868
}
6969
res.append(contentsOf: list)
7070
}
71-
71+
7272
return res
7373
}
7474
```
@@ -84,7 +84,7 @@ func subsets_a(_ nums: [Int]) -> [[Int]] {
8484
func subsetsWithDup(_ nums: [Int]) -> [[Int]] {
8585
var res = [[Int]]()
8686
let sortedNums = nums.sorted()
87-
87+
8888
func backtrack(start :Int, track: inout [Int]){
8989
res.append(track)
9090
for index in start..<sortedNums.count {
@@ -96,17 +96,17 @@ func subsetsWithDup(_ nums: [Int]) -> [[Int]] {
9696
track.popLast()
9797
}
9898
}
99-
99+
100100
var items = [Int]()
101101
backtrack(start: 0, track: &items)
102-
102+
103103
return res
104104
}
105105
```
106106

107107
### [permutations](https://leetcode-cn.com/problems/permutations/)
108108

109-
> 给定一个   没有重复   数字的序列,返回其所有可能的全排列
109+
> 给定一个 没有重复 数字的序列,返回其所有可能的全排列
110110

111111
思路:需要记录已经选择过的元素,满足条件的结果才进行返回
112112

@@ -118,7 +118,7 @@ func permute(_ nums: [Int]) -> [[Int]] {
118118
var res = [[Int]]()
119119
let count = nums.count
120120
var used = [Int :Bool]()
121-
121+
122122
func backtrack(track: inout [Int]){
123123
if track.count == count{
124124
res.append(track)
@@ -134,10 +134,10 @@ func permute(_ nums: [Int]) -> [[Int]] {
134134
track.popLast()
135135
}
136136
}
137-
137+
138138
var items = [Int]()
139139
backtrack( track: &items)
140-
140+
141141
return res
142142
}
143143
```
@@ -146,7 +146,7 @@ func permute(_ nums: [Int]) -> [[Int]] {
146146

147147
> 给定一个可包含重复数字的序列,返回所有不重复的全排列
148148

149-
![backtrack_permutations_ii](../images/backtrack_permutations_ii.png)
149+
![backtrack\_permutations\_ii](../.gitbook/assets/backtrack_permutations_ii.png)
150150

151151
```swift
152152
//https://leetcode-cn.com/problems/permutations-ii/solution/swift-47-quan-pai-lie-iipai-xu-hou-hui-su-you-hua-/
@@ -158,7 +158,7 @@ func permuteUnique(_ nums: [Int]) -> [[Int]] {
158158
var used = [Int :Bool]()
159159
let sortedNums = nums.sorted()
160160

161-
161+
162162
func backtrack(track: inout [Int]){
163163
if track.count == count{
164164
res.append(track)
@@ -167,41 +167,42 @@ func permuteUnique(_ nums: [Int]) -> [[Int]] {
167167
if used[index] ?? false {
168168
continue
169169
}
170-
170+
171171
// if index > 0 && sortedNums[index] == sortedNums[index - 1] && (used[index - 1] ?? false) {
172172
// continue
173173
// }
174174
//优化:提前剪枝
175175
if index > 0 && sortedNums[index] == sortedNums[index - 1] && !(used[index - 1]!) {
176176
continue
177177
}
178-
178+
179179
used[index] = true
180180
track.append(num)
181181
backtrack(track: &track)
182182
used[index] = false
183183
track.popLast()
184184
}
185185
}
186-
186+
187187
var items = [Int]()
188188
backtrack( track: &items)
189-
189+
190190
return res
191191
}
192192
```
193193

194194
## 练习
195195

196-
- [ ] [subsets](https://leetcode-cn.com/problems/subsets/)
197-
- [ ] [subsets-ii](https://leetcode-cn.com/problems/subsets-ii/)
198-
- [ ] [permutations](https://leetcode-cn.com/problems/permutations/)
199-
- [ ] [permutations-ii](https://leetcode-cn.com/problems/permutations-ii/)
196+
* [ ] [subsets](https://leetcode-cn.com/problems/subsets/)
197+
* [ ] [subsets-ii](https://leetcode-cn.com/problems/subsets-ii/)
198+
* [ ] [permutations](https://leetcode-cn.com/problems/permutations/)
199+
* [ ] [permutations-ii](https://leetcode-cn.com/problems/permutations-ii/)
200200

201201
挑战题目
202202

203-
- [ ] [combination-sum](https://leetcode-cn.com/problems/combination-sum/)
204-
- [ ] [letter-combinations-of-a-phone-number](https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/)
205-
- [ ] [palindrome-partitioning](https://leetcode-cn.com/problems/palindrome-partitioning/)
206-
- [ ] [restore-ip-addresses](https://leetcode-cn.com/problems/restore-ip-addresses/)
207-
- [ ] [permutations](https://leetcode-cn.com/problems/permutations/)
203+
* [ ] [combination-sum](https://leetcode-cn.com/problems/combination-sum/)
204+
* [ ] [letter-combinations-of-a-phone-number](https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/)
205+
* [ ] [palindrome-partitioning](https://leetcode-cn.com/problems/palindrome-partitioning/)
206+
* [ ] [restore-ip-addresses](https://leetcode-cn.com/problems/restore-ip-addresses/)
207+
* [ ] [permutations](https://leetcode-cn.com/problems/permutations/)
208+

‎advanced_algorithm/binary_search_tree.md renamed to ‎suan-fa-si-wei/binary_search_tree.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## 定义
44

5-
- 每个节点中的值必须大于(或等于)存储在其左侧子树中的任何值。
6-
- 每个节点中的值必须小于(或等于)存储在其右子树中的任何值。
5+
* 每个节点中的值必须大于(或等于)存储在其左侧子树中的任何值。
6+
* 每个节点中的值必须小于(或等于)存储在其右子树中的任何值。
77

88
## 应用
99

@@ -60,7 +60,6 @@ func Min(a,b int)int{
6060
}
6161
return a
6262
}
63-
6463
```
6564

6665
[insert-into-a-binary-search-tree](https://leetcode-cn.com/problems/insert-into-a-binary-search-tree/)
@@ -83,7 +82,7 @@ func insertIntoBST(root *TreeNode, val int) *TreeNode {
8382

8483
[delete-node-in-a-bst](https://leetcode-cn.com/problems/delete-node-in-a-bst/)
8584

86-
> 给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的  key  对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。
85+
> 给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。
8786
8887
```swift
8988
/**
@@ -136,10 +135,10 @@ func deleteNode(root *TreeNode, key int) *TreeNode {
136135
//内存消耗:21.5 MB, 在所有 Swift 提交中击败了100.00%的用户
137136
func maxDepth(_ root: TreeNode?) -> Int {
138137
guard let node = root else { return 0 }
139-
138+
140139
let leftNum = maxDepth(node.left)
141140
let rightNum = maxDepth(node.right)
142-
141+
143142
if leftNum > rightNum{
144143
return leftNum + 1
145144
}else{
@@ -153,24 +152,25 @@ func maxDepth(_ root: TreeNode?) -> Int {
153152
//内存消耗:22.3 MB, 在所有 Swift 提交中击败了100.00%的用户
154153
func isBalanced(_ root: TreeNode?) -> Bool {
155154
guard let node = root else { return true }
156-
155+
157156
if !isBalanced(node.left){
158157
return false
159158
}
160159
if !isBalanced(node.right){
161160
return false
162161
}
163-
162+
164163
let leftNum = maxDepth(node.left)
165164
let rightNum = maxDepth(node.right)
166-
165+
167166
return (abs(leftNum - rightNum) <= 1)
168167
}
169168
```
170169

171170
## 练习
172171

173-
- [ ] [validate-binary-search-tree](https://leetcode-cn.com/problems/validate-binary-search-tree/)
174-
- [ ] [insert-into-a-binary-search-tree](https://leetcode-cn.com/problems/insert-into-a-binary-search-tree/)
175-
- [ ] [delete-node-in-a-bst](https://leetcode-cn.com/problems/delete-node-in-a-bst/)
176-
- [ ] [balanced-binary-tree](https://leetcode-cn.com/problems/balanced-binary-tree/)
172+
* [ ] [validate-binary-search-tree](https://leetcode-cn.com/problems/validate-binary-search-tree/)
173+
* [ ] [insert-into-a-binary-search-tree](https://leetcode-cn.com/problems/insert-into-a-binary-search-tree/)
174+
* [ ] [delete-node-in-a-bst](https://leetcode-cn.com/problems/delete-node-in-a-bst/)
175+
* [ ] [balanced-binary-tree](https://leetcode-cn.com/problems/balanced-binary-tree/)
176+

‎advanced_algorithm/recursion.md renamed to ‎suan-fa-si-wei/recursion.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 递归
1+
# 递归思维
22

33
## 介绍
44

@@ -8,7 +8,7 @@
88

99
[reverse-string](https://leetcode-cn.com/problems/reverse-string/)
1010

11-
> 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组  `char[]`  的形式给出。
11+
> 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 `char[]` 的形式给出。
1212
1313
```swift
1414
//系统api
@@ -28,15 +28,14 @@ func reverseString_a(_ s: inout [Character]) {
2828
(s[left],s[right]) = (s[right],s[left])
2929
helper(&s, left + 1, right - 1)
3030
}
31-
31+
3232
helper(&s, 0, s.count-1)
3333
}
3434
```
3535

3636
[swap-nodes-in-pairs](https://leetcode-cn.com/problems/swap-nodes-in-pairs/)
3737

38-
> 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。
39-
> **你不能只是单纯的改变节点内部的值**,而是需要实际的进行节点交换。
38+
> 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。 **你不能只是单纯的改变节点内部的值**,而是需要实际的进行节点交换。
4039
4140
```swift
4241
public class ListNode {
@@ -54,7 +53,7 @@ func swapPairs(_ head: ListNode?) -> ListNode? {
5453
guard let item = head, let next = item.next else {
5554
return head
5655
}
57-
56+
5857
let nextNext = next.next
5958
next.next = item
6059
let new = swapPairs(nextNext)
@@ -65,7 +64,7 @@ func swapPairs(_ head: ListNode?) -> ListNode? {
6564

6665
[unique-binary-search-trees-ii](https://leetcode-cn.com/problems/unique-binary-search-trees-ii/)
6766

68-
> 给定一个整数 n,生成所有由 1 ... n 为节点所组成的二叉搜索树。
67+
> 给定一个整数 n,生成所有由 1 ... n 为节点所组成的二叉搜索树。
6968
7069
```swift
7170
public class TreeNode {
@@ -89,7 +88,7 @@ func generateTrees(_ n: Int) -> [TreeNode?] {
8988
guard n <= 0 else {
9089
return []
9190
}
92-
91+
9392
func helper(_ start: Int, _ end: Int) -> [TreeNode?]{
9493
if start > end {
9594
return [nil]
@@ -98,7 +97,7 @@ func generateTrees(_ n: Int) -> [TreeNode?] {
9897
for rootVal in start...end {
9998
let leftTrees = helper(start,rootVal - 1)
10099
let rightTrees = helper(rootVal + 1,end)
101-
100+
102101
for leftItem in leftTrees {
103102
for rightItem in rightTrees {
104103
let root = TreeNode(rootVal)
@@ -110,7 +109,7 @@ func generateTrees(_ n: Int) -> [TreeNode?] {
110109
}
111110
return trees
112111
}
113-
112+
114113
return helper(1, n)
115114
}
116115

@@ -121,10 +120,7 @@ func generateTrees(_ n: Int) -> [TreeNode?] {
121120

122121
[fibonacci-number](https://leetcode-cn.com/problems/fibonacci-number/)
123122

124-
> 斐波那契数,通常用  F(n) 表示,形成的序列称为斐波那契数列。该数列由  0 和 1 开始,后面的每一项数字都是前面两项数字的和。也就是:
125-
> F(0) = 0,   F(1) = 1
126-
> F(N) = F(N - 1) + F(N - 2), 其中 N > 1.
127-
> 给定  N,计算  F(N)。
123+
> 斐波那契数,通常用 F\(n\) 表示,形成的序列称为斐波那契数列。该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和。也就是: F\(0\) = 0, F\(1\) = 1 F\(N\) = F\(N - 1\) + F\(N - 2\), 其中 N &gt; 1. 给定 N,计算 F\(N\)
128124
129125
```swift
130126
//https://leetcode-cn.com/problems/fibonacci-number/solution/swift-di-gui-huan-cun-by-hu-cheng-he-da-bai-sha/
@@ -144,15 +140,16 @@ func fib(_ N: Int) -> Int {
144140
cache[n] = res
145141
return res
146142
}
147-
143+
148144
return helper(N)
149145
}
150146
//fib(100)
151147
```
152148

153149
## 练习
154150

155-
- [ ] [reverse-string](https://leetcode-cn.com/problems/reverse-string/)
156-
- [ ] [swap-nodes-in-pairs](https://leetcode-cn.com/problems/swap-nodes-in-pairs/)
157-
- [ ] [unique-binary-search-trees-ii](https://leetcode-cn.com/problems/unique-binary-search-trees-ii/)
158-
- [ ] [fibonacci-number](https://leetcode-cn.com/problems/fibonacci-number/)
151+
* [ ] [reverse-string](https://leetcode-cn.com/problems/reverse-string/)
152+
* [ ] [swap-nodes-in-pairs](https://leetcode-cn.com/problems/swap-nodes-in-pairs/)
153+
* [ ] [unique-binary-search-trees-ii](https://leetcode-cn.com/problems/unique-binary-search-trees-ii/)
154+
* [ ] [fibonacci-number](https://leetcode-cn.com/problems/fibonacci-number/)
155+

‎advanced_algorithm/slide_window.md renamed to ‎suan-fa-si-wei/slide_window.md

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
# 滑动窗口
1+
# 滑动窗口思想
22

33
## 模板
44

55
```swift
66
/* 滑动窗口算法框架 */
77
func slidingWindow(_ s: String, _ t: String) {
88
let sArray = [Character](s)
9-
9+
1010
var win = Dictionary<Character, Int>() // 保存滑动窗口字符集
1111
var need = Dictionary<Character, Int>() // 保存需要的字符集
12-
12+
1313
for c in t {
1414
need[c, default: 0] += 1
1515
}
16-
16+
1717
var left = 0 ,right = 0 // 窗口
1818
var valid = 0 // 匹配次数
19-
19+
2020
while right < sArray.count {
21-
// rightItem 是将移入窗口的字符
21+
// rightItem 是将移入窗口的字符
2222
let rightItem = sArray[right]
23-
// 右移窗口
23+
// 右移窗口
2424
right += 1
2525
// 进行窗口内数据的一系列更新
2626
...
2727

2828
/*** debug 输出的位置 ***/
2929
print("window: [\(left), \(right))\n", left, right);
3030
/********************/
31-
3231

33-
// 判断左侧窗口是否要收缩
32+
33+
// 判断左侧窗口是否要收缩
3434
while (window needs shrink) {
3535
// d 是将移出窗口的字符
3636
let leftItem = sArray[left]
@@ -75,10 +75,10 @@ void slidingWindow(string s, string t) {
7575

7676
需要变化的地方
7777

78-
- 1、右指针右移之后窗口数据更新
79-
- 2、判断窗口是否要收缩
80-
- 3、左指针右移之后窗口数据更新
81-
- 4、根据题意计算结果
78+
* 1、右指针右移之后窗口数据更新
79+
* 2、判断窗口是否要收缩
80+
* 3、左指针右移之后窗口数据更新
81+
* 4、根据题意计算结果
8282

8383
## 示例
8484

@@ -92,19 +92,19 @@ void slidingWindow(string s, string t) {
9292
//内存消耗:15.5 MB, 在所有 Swift 提交中击败了96.67%的用户
9393
func minWindow(_ s: String, _ t: String) -> String {
9494
let sArray = [Character](s)
95-
95+
9696
var win = Dictionary<Character, Int>() // 保存滑动窗口字符集
9797
var need = Dictionary<Character, Int>() // 保存需要的字符集
98-
98+
9999
for c in t {
100100
need[c, default: 0] += 1
101101
}
102-
102+
103103
var left = 0 ,right = 0 // 窗口
104104
var match = 0 // match匹配次数
105105
var start = 0 , end = 0
106106
var minLength = Int.max
107-
107+
108108
while right < sArray.count {
109109
let rightItem = sArray[right]
110110
right += 1
@@ -118,15 +118,15 @@ func minWindow(_ s: String, _ t: String) -> String {
118118
}else{
119119
continue
120120
}
121-
121+
122122
// 当所有字符数量都匹配之后,开始缩紧窗口
123123
while match == need.count {
124124
if right - left < minLength {
125125
start = left
126126
end = right
127127
minLength = end - start
128128
}
129-
129+
130130
let leftItem = sArray[left]
131131
left += 1
132132
// 左指针指向不在需要字符集则直接跳过
@@ -141,33 +141,33 @@ func minWindow(_ s: String, _ t: String) -> String {
141141
}
142142
}
143143
}
144-
144+
145145
return minLength == Int.max ? "" : String(sArray[start..<end])
146146
}
147147
//print(minWindow("ADOBECODEBANC","ABC"))
148148
```
149149

150150
[permutation-in-string](https://leetcode-cn.com/problems/permutation-in-string/)
151151

152-
> 给定两个字符串  **s1**  **s2**,写一个函数来判断  **s2**  是否包含  **s1** 的排列。
152+
> 给定两个字符串 **s1****s2**,写一个函数来判断 **s2** 是否包含 **s1** 的排列。
153153
154154
```swift
155155
//https://leetcode-cn.com/problems/permutation-in-string/solution/swift-hua-dong-chuang-kou-by-hu-cheng-he-da-bai-sh/
156156
//执行用时:456 ms, 在所有 Swift 提交中击败了47.06%的用户
157157
//内存消耗:13.9 MB, 在所有 Swift 提交中击败了100.00%的用户
158158
func checkInclusion(_ s1: String, _ s2: String) -> Bool {
159159
let s2Array = [Character](s2)
160-
160+
161161
var win = Dictionary<Character, Int>() // 保存滑动窗口字符集
162162
var need = Dictionary<Character, Int>() // 保存需要的字符集
163-
163+
164164
for c in s1 {
165165
need[c, default: 0] += 1
166166
}
167-
167+
168168
var left = 0 ,right = 0 // 窗口
169169
var match = 0 // match匹配次数
170-
170+
171171
while right < s2Array.count {
172172
let rightItem = s2Array[right]
173173
right += 1
@@ -181,13 +181,13 @@ func checkInclusion(_ s1: String, _ s2: String) -> Bool {
181181
}else{
182182
continue
183183
}
184-
184+
185185
// 当所有字符数量都匹配之后,开始缩紧窗口
186186
while match == need.count {
187187
if right - left == s1.count {
188188
return true
189189
}
190-
190+
191191
let leftItem = s2Array[left]
192192
left += 1
193193
// 左指针指向不在需要字符集则直接跳过
@@ -208,26 +208,26 @@ func checkInclusion(_ s1: String, _ s2: String) -> Bool {
208208

209209
[find-all-anagrams-in-a-string](https://leetcode-cn.com/problems/find-all-anagrams-in-a-string/)
210210

211-
> 给定一个字符串  **s** 和一个非空字符串  **p**,找到  **s** 中所有是  **p** 的字母异位词的子串,返回这些子串的起始索引。
211+
> 给定一个字符串 **s** 和一个非空字符串 **p**,找到 **s** 中所有是 **p** 的字母异位词的子串,返回这些子串的起始索引。
212212
213213
```swift
214214
//https://leetcode-cn.com/problems/find-all-anagrams-in-a-string/solution/swift-hua-dong-chuang-kou-by-hu-cheng-he-da-bai--2/
215215
//执行用时:2008 ms, 在所有 Swift 提交中击败了16.67%的用户
216216
//内存消耗:14.7 MB, 在所有 Swift 提交中击败了100.00%的用户
217217
func findAnagrams(_ s: String, _ p: String) -> [Int] {
218218
let sArray = [Character](s)
219-
219+
220220
var win = [Character: Int]() // 保存滑动窗口字符集
221221
var need = [Character: Int]() // 保存需要的字符集
222-
222+
223223
for c in p {
224224
need[c, default: 0] += 1
225225
}
226-
226+
227227
var left = 0 ,right = 0 // 窗口
228228
var match = 0 // match匹配次数
229229
var startIndexs = [Int]()
230-
230+
231231
while right < sArray.count {
232232
let rightItem = sArray[right]
233233
right += 1
@@ -241,12 +241,12 @@ func findAnagrams(_ s: String, _ p: String) -> [Int] {
241241
}else{
242242
continue
243243
}
244-
244+
245245
while match == need.count {
246246
if right - left == p.count {
247247
startIndexs.append(left)
248248
}
249-
249+
250250
let leftItem = sArray[left]
251251
left += 1
252252
if let needItem = need[leftItem] {
@@ -257,32 +257,29 @@ func findAnagrams(_ s: String, _ p: String) -> [Int] {
257257
}
258258
}
259259
}
260-
260+
261261
return startIndexs
262262
}
263263
```
264264

265265
[longest-substring-without-repeating-characters](https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/)
266266

267-
> 给定一个字符串,请你找出其中不含有重复字符的   最长子串   的长度。
268-
> 示例  1:
267+
> 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1:
269268
>
270-
> 输入: "abcabcbb"
271-
> 输出: 3
272-
> 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
269+
> 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
273270
274271
```swift
275272
//https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/solution/swift-hua-dong-chuang-kou-by-hu-cheng-he-da-bai--2/
276273
//执行用时:76 ms, 在所有 Swift 提交中击败了59.25%的用户
277274
//内存消耗:14.4 MB, 在所有 Swift 提交中击败了89.78%的用户
278275
func lengthOfLongestSubstring(_ s: String) -> Int {
279276
let sArray = [Character](s)
280-
277+
281278
var win = Dictionary<Character, Int>()
282-
279+
283280
var left = 0 ,right = 0 // 窗口
284281
var maxLength = 0
285-
282+
286283
while right < sArray.count {
287284
let rightItem = sArray[right]
288285
right += 1
@@ -294,23 +291,24 @@ func lengthOfLongestSubstring(_ s: String) -> Int {
294291
}
295292
maxLength = max(maxLength,right - left)
296293
}
297-
294+
298295
return maxLength
299296
}
300297
```
301298

302299
## 总结
303300

304-
- 和双指针题目类似,更像双指针的升级版,滑动窗口核心点是维护一个窗口集,根据窗口集来进行处理
305-
- 核心步骤
306-
- right 右移
307-
- 收缩
308-
- left 右移
309-
- 求结果
301+
* 和双指针题目类似,更像双指针的升级版,滑动窗口核心点是维护一个窗口集,根据窗口集来进行处理
302+
* 核心步骤
303+
* right 右移
304+
* 收缩
305+
* left 右移
306+
* 求结果
310307

311308
## 练习
312309

313-
- [ ] [minimum-window-substring](https://leetcode-cn.com/problems/minimum-window-substring/)
314-
- [ ] [permutation-in-string](https://leetcode-cn.com/problems/permutation-in-string/)
315-
- [ ] [find-all-anagrams-in-a-string](https://leetcode-cn.com/problems/find-all-anagrams-in-a-string/)
316-
- [ ] [longest-substring-without-repeating-characters](https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/)
310+
* [ ] [minimum-window-substring](https://leetcode-cn.com/problems/minimum-window-substring/)
311+
* [ ] [permutation-in-string](https://leetcode-cn.com/problems/permutation-in-string/)
312+
* [ ] [find-all-anagrams-in-a-string](https://leetcode-cn.com/problems/find-all-anagrams-in-a-string/)
313+
* [ ] [longest-substring-without-repeating-characters](https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/)
314+

0 commit comments

Comments
 (0)
Please sign in to comment.