Skip to content

Commit a8b66cd

Browse files
代码重构 【Github Actions】
1 parent 5a5325b commit a8b66cd

38 files changed

+110
-159
lines changed

animation-simulation/二分查找及其变种/leetcode33不完全有序查找目标元素(不包含重复值).md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ func search(nums []int, target int) int {
157157
}
158158
```
159159

160-
##
160+
##

animation-simulation/二分查找及其变种/leetcode35搜索插入位置.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
>
33
> 感谢支持,该仓库会一直维护,希望对各位有一丢丢帮助。
44
>
5-
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
5+
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
66
77
#### [35. 搜索插入位置](https://leetcode-cn.com/problems/search-insert-position/)
88

@@ -52,10 +52,10 @@ class Solution {
5252
//查询成功
5353
if (target == nums[mid]) {
5454
return mid;
55-
//右区间
55+
//右区间
5656
} else if (nums[mid] < target) {
57-
left = mid + 1;
58-
//左区间
57+
left = mid + 1;
58+
//左区间
5959
} else if (nums[mid] > target) {
6060
right = mid - 1;
6161
}

animation-simulation/二叉树/二叉树中序遍历(迭代).md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Solution {
3434
TreeNode cur = new TreeNode(-1);
3535
cur = root;
3636
Stack<TreeNode> stack = new Stack<>();
37-
while (!stack.isEmpty() || cur != null) {
37+
while (!stack.isEmpty() || cur != null) {
3838
//找到当前应该遍历的那个节点
3939
while (cur != null) {
4040
stack.push(cur);
@@ -47,7 +47,7 @@ class Solution {
4747
cur = temp.right;
4848
}
4949
return arr;
50-
}
50+
}
5151
}
5252
```
5353

@@ -104,4 +104,4 @@ func inorderTraversal(root *TreeNode) []int {
104104
}
105105
```
106106

107-
###
107+
###

animation-simulation/二叉树/二叉树的前序遍历(栈).md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class Solution {
4949
public List<Integer> preorderTraversal(TreeNode root) {
5050
List<Integer> list = new ArrayList<>();
5151
Stack<TreeNode> stack = new Stack<>();
52-
if (root == null) return list;
52+
if (root == null) return list;
5353
stack.push(root);
5454
while (!stack.isEmpty()) {
55-
TreeNode temp = stack.pop();
55+
TreeNode temp = stack.pop();
5656
if (temp.right != null) {
5757
stack.push(temp.right);
5858
}

animation-simulation/二叉树/二叉树的后续遍历 (迭代).md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
我们知道后序遍历的顺序是,` 对于树中的某节点, 先遍历该节点的左子树, 再遍历其右子树, 最后遍历该节点`
1414

15-
那么我们如何利用栈来解决呢?
15+
那么我们如何利用栈来解决呢?
1616

1717
我们直接来看动画,看动画之前,但是我们`需要带着问题看动画`,问题搞懂之后也就搞定了后序遍历。
1818

animation-simulation/单调队列单调栈/leetcode739每日温度.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ func dailyTemperatures(temperatures []int) []int {
8080
}
8181
return arr
8282
}
83+
```

animation-simulation/单调队列单调栈/剑指offer59队列的最大值.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (mq *MaxQueue) Is_empty() bool {
111111
return mq.size == 0
112112
}
113113

114-
// Max_value 取最大值值,返回我们双端队列的对头即可,因为我们双端队列是单调递减的嘛
114+
// Max_value 取最大值值,返回我们双端队列的对头即可,因为我们双端队列是单调递减的嘛
115115
func (mq *MaxQueue) Max_value() int {
116116
if mq.Is_empty() { return -1 }
117117
return mq.deq[0]

animation-simulation/单调队列单调栈/最小栈.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,5 @@ func (m *MinStack) GetMin() int {
116116
return m.minStk[len(m.minStk) - 1]
117117
}
118118
```
119+
119120
###

animation-simulation/数组篇/leetcode1438绝对值不超过限制的最长子数组.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ class Solution {
261261
}
262262
```
263263

264-
265264
Go Code:
266265

267266
```go
@@ -304,4 +303,3 @@ func max(a, b int) int {
304303
return b
305304
}
306305
```
307-

animation-simulation/数组篇/leetcode1两数之和.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ class Solution {
203203
}
204204
```
205205

206-
207206
Go Code:
208207

209208
```go
@@ -218,4 +217,3 @@ func twoSum(nums []int, target int) []int {
218217
return []int{}
219218
}
220219
```
221-

animation-simulation/数组篇/leetcode219数组中重复元素2.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Solution {
4545
if (map.containsKey(nums[i])) {
4646
//判断是否小于K,如果小于等于则直接返回
4747
int abs = Math.abs(i - map.get(nums[i]));
48-
if (abs <= k) return true;//小于等于则返回
48+
if (abs <= k) return true;//小于等于则返回
4949
}
5050
//更新索引,此时有两种情况,不存在,或者存在时,将后出现的索引保存
5151
map.put(nums[i],i);
@@ -72,7 +72,7 @@ class Solution:
7272
# 判断是否小于K,如果小于等于则直接返回
7373
a = abs(i - m[nums[i]])
7474
if a <= k:
75-
return True# 小于等于则返回
75+
return True# 小于等于则返回
7676
# 更新索引,此时有两种情况,不存在,或者存在时,将后出现的索引保存
7777
m[nums[i]] = i
7878
return False
@@ -243,4 +243,3 @@ func containsNearbyDuplicate(nums []int, k int) bool {
243243
return false
244244
}
245245
```
246-

animation-simulation/数组篇/leetcode27移除元素.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ class Solution {
183183
}
184184
```
185185

186-
187186
Go Code:
188187

189188
```go
@@ -203,4 +202,3 @@ func removeElement(nums []int, val int) int {
203202
return i
204203
}
205204
```
206-

animation-simulation/数组篇/leetcode41缺失的第一个正数.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ public:
274274
};
275275
```
276276
277-
278277
Go Code:
279278
280279
```go
@@ -297,4 +296,3 @@ func firstMissingPositive(nums []int) int {
297296
return length + 1
298297
}
299298
```
300-

animation-simulation/数组篇/leetcode485最大连续1的个数.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
下面我们通过一个视频模拟代码执行步骤大家一下就能搞懂了。
2424

25-
![leetcode485最长连续1的个数](https://cdn.jsdelivr.net/gh/tan45du/test1@master/20210122/leetcode485最长连续1的个数.7avzcthkit80.gif)
25+
![leetcode485最长连续1的个数](https://cdn.jsdelivr.net/gh/tan45du/test1@master/20210122/leetcode485最长连续1的个数.7avzcthkit80.gif)
2626

2727
下面我们直接看代码吧
2828

@@ -231,4 +231,3 @@ func max(a, b int) int {
231231
return b
232232
}
233233
```
234-

animation-simulation/数组篇/leetcode54螺旋矩阵.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ class Solution {
181181
}
182182
```
183183

184-
185184
Go Code:
186185

187186
```go
@@ -208,7 +207,7 @@ func spiralOrder(matrix [][]int) []int {
208207
}
209208
down--
210209
if top > down { break }
211-
210+
212211
for i := down; i >= top; i-- {
213212
res = append(res, matrix[i][left])
214213
}
@@ -218,4 +217,3 @@ func spiralOrder(matrix [][]int) []int {
218217
return res
219218
}
220219
```
221-

animation-simulation/数组篇/leetcode560和为K的子数组.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,3 @@ func subarraySum(nums []int, k int) int {
236236
return cnt
237237
}
238238
```
239-

animation-simulation/数组篇/leetcode59螺旋矩阵2.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ class Solution {
361361
}
362362
```
363363

364-
365364
Go Code:
366365

367366
```go
@@ -394,7 +393,7 @@ func generateMatrix(n int) [][]int {
394393
}
395394
buttom--
396395
if num > size { break }
397-
396+
398397
for i := buttom; i >= top; i-- {
399398
res[i][left] = num
400399
num++
@@ -405,4 +404,3 @@ func generateMatrix(n int) [][]int {
405404
return res
406405
}
407406
```
408-

animation-simulation/数组篇/leetcode66加一.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
>
33
> 感谢支持,该仓库会一直维护,希望对各位有一丢丢帮助。
44
>
5-
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
5+
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
66
77
#### [66. 加一](https://leetcode-cn.com/problems/plus-one/)
88

@@ -56,10 +56,10 @@ class Solution {
5656
if (digits[i] != 0) {
5757
return digits;
5858
}
59-
59+
6060
}
6161
//第三种情况,因为数组初始化每一位都为0,我们只需将首位设为1即可
62-
int[] arr = new int[len+1];
62+
int[] arr = new int[len+1];
6363
arr[0] = 1;
6464
return arr;
6565
}
@@ -138,4 +138,3 @@ func plusOne(digits []int) []int {
138138
return digits
139139
}
140140
```
141-

animation-simulation/数组篇/leetcode75颜色分类.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Solution {
4848
//这里和三向切分不完全一致
4949
int i = left;
5050
int right = len-1;
51-
51+
5252
while (i <= right) {
5353
if (nums[i] == 2) {
5454
swap(nums,i,right--);
@@ -57,7 +57,7 @@ class Solution {
5757
} else {
5858
i++;
5959
}
60-
}
60+
}
6161
}
6262
public void swap (int[] nums, int i, int j) {
6363
int temp = nums[i];
@@ -72,7 +72,7 @@ Python3 Code:
7272
```python
7373
from typing import List
7474
class Solution:
75-
def sortColors(self, nums: List[int]):
75+
def sortColors(self, nums: List[int]):
7676
leng = len(nums)
7777
left = 0
7878
# 这里和三向切分不完全一致
@@ -89,7 +89,7 @@ class Solution:
8989
else:
9090
i += 1
9191
return nums
92-
92+
9393
def swap(self, nums: List[int], i: int, j: int):
9494
temp = nums[i]
9595
nums[i] = nums[j]
@@ -112,7 +112,7 @@ public:
112112
} else {
113113
i++;
114114
}
115-
}
115+
}
116116
}
117117
};
118118
```
@@ -173,8 +173,6 @@ func sortColors(nums []int) {
173173
}
174174
```
175175

176-
177-
178176
另外我们看这段代码,有什么问题呢?那就是我们即使完全符合时,仍会交换元素,这样会大大降低我们的效率。
179177

180178
例如:[0,0,0,1,1,1,2,2,2]
@@ -203,7 +201,7 @@ class Solution {
203201
int len = nums.length;
204202
int right = len - 1;
205203
for (int i = 0; i <= right; ++i) {
206-
if (nums[i] == 0) {
204+
if (nums[i] == 0) {
207205
swap(nums,i,left);
208206
left++;
209207
}
@@ -216,7 +214,7 @@ class Solution {
216214
}
217215
}
218216
}
219-
217+
220218
}
221219
public void swap (int[] nums,int i, int j) {
222220
int temp = nums[i];
@@ -246,7 +244,7 @@ class Solution:
246244
# 如果不等于 1 则需要继续判断,所以不移动 i 指针,i--
247245
if nums[i] != 1:
248246
i -= 1
249-
i += 1
247+
i += 1
250248
return nums
251249

252250
def swap(self, nums: List[int], i: int, j: int):
@@ -264,7 +262,7 @@ public:
264262
int left = 0, len = nums.size();
265263
int right = len - 1;
266264
for (int i = 0; i <= right; ++i) {
267-
if (nums[i] == 0) {
265+
if (nums[i] == 0) {
268266
swap(nums[i],nums[left++]);
269267
}
270268
if (nums[i] == 2) {
@@ -291,7 +289,7 @@ class Solution {
291289
//nums.swapAt(i, left) 直接调用系统方法
292290
self.swap(&nums, i, left) // 保持风格统一走自定义交换
293291
left += 1
294-
}
292+
}
295293
if nums[i] == 2 {
296294
//nums.swapAt(i, right) 直接调用系统方法
297295
self.swap(&nums, i, right) // 保持风格统一走自定义交换
@@ -336,4 +334,3 @@ func sortColors(nums []int) {
336334
}
337335
}
338336
```
339-

animation-simulation/数组篇/剑指offer3数组中重复的数.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
>
33
> 感谢支持,该仓库会一直维护,希望对各位有一丢丢帮助。
44
>
5-
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
5+
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
66
77
#### [剑指 Offer 03. 数组中重复的数字](https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/)
88

@@ -16,7 +16,7 @@
1616

1717
输入:
1818
[2, 3, 1, 0, 2, 5, 3]
19-
输出:2 或 3
19+
输出:2 或 3
2020

2121
#### **HashSet**
2222

animation-simulation/数组篇/长度最小的子数组.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ class Solution {
120120
}
121121
```
122122

123-
124123
Go Code:
125124

126125
```go
@@ -150,4 +149,3 @@ func min(a, b int) int {
150149
return b
151150
}
152151
```
153-

0 commit comments

Comments
 (0)