Skip to content

Commit 0b82714

Browse files
authored
Merge branch 'youngyangyang04:master' into master
2 parents c5a6c3e + 672374d commit 0b82714

File tree

245 files changed

+2383
-1049
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+2383
-1049
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
👉 推荐 [Gitee同步](https://gitee.com/programmercarl/leetcode-master)
44

55
> 1. **介绍** :本项目是一套完整的刷题计划,旨在帮助大家少走弯路,循序渐进学算法,[关注作者](#关于作者)
6-
> 2. **正式出版**[《代码随想录》](https://programmercarl.com/other/publish.html)
7-
> 3. **PDF版本**[「代码随想录」算法精讲 PDF 版本](https://programmercarl.com/other/algo_pdf.html)
6+
> 2. **正式出版**[《代码随想录》](https://programmercarl.com/qita/publish.html)
7+
> 3. **PDF版本**[「代码随想录」算法精讲 PDF 版本](https://programmercarl.com/qita/algo_pdf.html)
88
> 4. **算法公开课**[《代码随想录》算法视频公开课](https://www.bilibili.com/video/BV1fA4y1o715)
99
> 5. **最强八股文**[代码随想录知识星球精华PDF](https://www.programmercarl.com/other/kstar_baguwen.html)
1010
> 6. **刷题顺序** :README已经将刷题顺序排好了,按照顺序一道一道刷就可以。
@@ -14,7 +14,7 @@
1414
1515

1616
<p align="center">
17-
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
17+
<a href="https://programmercarl.com/xunlian/xunlianying.html" target="_blank">
1818
<img src="./pics/训练营.png" width="800"/>
1919
</a>
2020
</p>
@@ -78,18 +78,6 @@
7878
* [Java语言基础课](https://kamacoder.com/course.php?course_id=2)
7979
* [23种设计模式](https://github.com/youngyangyang04/kama-DesignPattern)
8080

81-
* 项目
82-
* [基于跳表的轻量级KV存储引擎](https://github.com/youngyangyang04/Skiplist-CPP)
83-
* [Nosql数据库注入攻击系统](https://github.com/youngyangyang04/NoSQLAttack)
84-
85-
* 编程素养
86-
* [看了这么多代码,谈一谈代码风格!](./problems/前序/代码风格.md)
87-
* [力扣上的代码想在本地编译运行?](./problems/前序/力扣上的代码想在本地编译运行?.md)
88-
* [什么是核心代码模式,什么又是ACM模式?](./problems/前序/什么是核心代码模式,什么又是ACM模式?.md)
89-
* [刷题要不要用库函数](./problems/前序/刷力扣用不用库函数.md)
90-
* [ACM模式如何构造二叉树](./problems/前序/ACM模式如何构建二叉树.md)
91-
* [解密互联网大厂研发流程](./problems/前序/互联网大厂研发流程.md)
92-
9381
* 工具
9482
* [一站式vim配置](https://github.com/youngyangyang04/PowerVim)
9583
* [保姆级Git入门教程,万字详解](https://mp.weixin.qq.com/s/Q_O0ey4C9tryPZaZeJocbA)
@@ -106,7 +94,6 @@
10694
* [关于时间复杂度,你不知道的都在这里!](./problems/前序/关于时间复杂度,你不知道的都在这里!.md)
10795
* [O(n)的算法居然超时了,此时的n究竟是多大?](./problems/前序/On的算法居然超时了,此时的n究竟是多大?.md)
10896
* [通过一道面试题目,讲一讲递归算法的时间复杂度!](./problems/前序/通过一道面试题目,讲一讲递归算法的时间复杂度!.md)
109-
* [本周小结!(算法性能分析系列一)](./problems/周总结/20201210复杂度分析周末总结.md)
11097
* [关于空间复杂度,可能有几个疑问?](./problems/前序/关于空间复杂度,可能有几个疑问?.md)
11198
* [递归算法的时间与空间复杂度分析!](./problems/前序/递归算法的时间与空间复杂度分析.md)
11299
* [刷了这么多题,你了解自己代码的内存消耗么?](./problems/前序/刷了这么多题,你了解自己代码的内存消耗么?.md)
@@ -499,7 +486,7 @@
499486

500487
# 贡献者
501488

502-
[点此这里](https://github.com/youngyangyang04/leetcode-master/graphs/contributors)查看LeetCode-Master的所有贡献者。感谢他们补充了LeetCode-Master的其他语言版本,让更多的读者收益于此项目
489+
[点此这里](https://github.com/youngyangyang04/leetcode-master/graphs/contributors)查看LeetCode-Master的所有贡献者。感谢他们补充了LeetCode-Master的其他语言版本,让更多的读者受益于此项目
503490

504491
# Star 趋势
505492

pics/网站星球宣传海报.jpg

-129 KB
Loading

problems/0001.两数之和.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<p align="center">
2-
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
2+
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
33
<img src="../pics/训练营.png" width="1000"/>
44
</a>
5-
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
5+
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
66

77

88
# 1. 两数之和
@@ -537,8 +537,8 @@ int* twoSum(int* nums, int numsSize, int target, int* returnSize){
537537
return NULL;
538538
}
539539
```
540+
540541
<p align="center">
541542
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
542543
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
543544
</a>
544-

problems/0005.最长回文子串.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<p align="center">
2-
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
2+
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
33
<img src="../pics/训练营.png" width="1000"/>
44
</a>
5-
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
5+
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
66

77

88

@@ -677,8 +677,8 @@ public class Solution {
677677
}
678678
```
679679

680+
680681
<p align="center">
681682
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
682683
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
683684
</a>
684-

problems/0015.三数之和.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<p align="center">
2-
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
2+
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
33
<img src="../pics/训练营.png" width="1000"/>
44
</a>
5-
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
5+
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
66

77

88

9-
> 用哈希表解决了[两数之和](https://programmercarl.com/0001.两数之和.html),那么三数之和呢?
10-
119
# 第15题. 三数之和
1210

1311
[力扣题目链接](https://leetcode.cn/problems/3sum/)
@@ -938,8 +936,8 @@ object Solution {
938936
}
939937
}
940938
```
939+
941940
<p align="center">
942941
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
943942
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
944943
</a>
945-

problems/0017.电话号码的字母组合.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<p align="center">
2-
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
2+
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
33
<img src="../pics/训练营.png" width="1000"/>
44
</a>
5-
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
5+
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
66

77

88
# 17.电话号码的字母组合
@@ -765,8 +765,8 @@ public class Solution
765765
}
766766
```
767767

768+
768769
<p align="center">
769770
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
770771
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
771772
</a>
772-

problems/0018.四数之和.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<p align="center">
2-
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
2+
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
33
<img src="../pics/训练营.png" width="1000"/>
44
</a>
5-
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
5+
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
66

77

88
> 一样的道理,能解决四数之和
@@ -697,8 +697,8 @@ def four_sum(nums, target)
697697
return result
698698
end
699699
```
700+
700701
<p align="center">
701702
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
702703
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
703704
</a>
704-

problems/0019.删除链表的倒数第N个节点.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<p align="center">
2-
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
2+
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
33
<img src="../pics/训练营.png" width="1000"/>
44
</a>
5-
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
5+
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
66

77

88

@@ -98,27 +98,33 @@ public:
9898
### Java:
9999
100100
```java
101-
public ListNode removeNthFromEnd(ListNode head, int n){
102-
ListNode dummyNode = new ListNode(0);
103-
dummyNode.next = head;
104-
105-
ListNode fastIndex = dummyNode;
106-
ListNode slowIndex = dummyNode;
101+
class Solution {
102+
public ListNode removeNthFromEnd(ListNode head, int n) {
103+
//新建一个虚拟头节点指向head
104+
ListNode dummyNode = new ListNode(0);
105+
dummyNode.next = head;
106+
//快慢指针指向虚拟头节点
107+
ListNode fastIndex = dummyNode;
108+
ListNode slowIndex = dummyNode;
109+
110+
// 只要快慢指针相差 n 个结点即可
111+
for (int i = 0; i <= n; i++) {
112+
fastIndex = fastIndex.next;
113+
}
107114
108-
// 只要快慢指针相差 n 个结点即可
109-
for (int i = 0; i < n ; i++){
110-
fastIndex = fastIndex.next;
111-
}
115+
while (fastIndex != null) {
116+
fastIndex = fastIndex.next;
117+
slowIndex = slowIndex.next;
118+
}
112119
113-
while (fastIndex != null){
114-
fastIndex = fastIndex.next;
115-
slowIndex = slowIndex.next;
120+
// 此时 slowIndex 的位置就是待删除元素的前一个位置。
121+
// 具体情况可自己画一个链表长度为 3 的图来模拟代码来理解
122+
// 检查 slowIndex.next 是否为 null,以避免空指针异常
123+
if (slowIndex.next != null) {
124+
slowIndex.next = slowIndex.next.next;
125+
}
126+
return dummyNode.next;
116127
}
117-
118-
//此时 slowIndex 的位置就是待删除元素的前一个位置。
119-
//具体情况可自己画一个链表长度为 3 的图来模拟代码来理解
120-
slowIndex.next = slowIndex.next.next;
121-
return dummyNode.next;
122128
}
123129
```
124130

problems/0020.有效的括号.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<p align="center">
2-
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
2+
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
33
<img src="../pics/训练营.png" width="1000"/>
44
</a>
5-
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
5+
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>
66

77

88

0 commit comments

Comments
 (0)