Skip to content

Commit

Permalink
Merge branch 'youngyangyang04:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
qiufeihong2018 committed Apr 29, 2024
2 parents 2d37cd3 + c94895d commit 49ae4d4
Show file tree
Hide file tree
Showing 244 changed files with 2,369 additions and 1,040 deletions.
21 changes: 4 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
👉 推荐 [Gitee同步](https://gitee.com/programmercarl/leetcode-master)

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

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

* 项目
* [基于跳表的轻量级KV存储引擎](https://github.com/youngyangyang04/Skiplist-CPP)
* [Nosql数据库注入攻击系统](https://github.com/youngyangyang04/NoSQLAttack)

* 编程素养
* [看了这么多代码,谈一谈代码风格!](./problems/前序/代码风格.md)
* [力扣上的代码想在本地编译运行?](./problems/前序/力扣上的代码想在本地编译运行?.md)
* [什么是核心代码模式,什么又是ACM模式?](./problems/前序/什么是核心代码模式,什么又是ACM模式?.md)
* [刷题要不要用库函数](./problems/前序/刷力扣用不用库函数.md)
* [ACM模式如何构造二叉树](./problems/前序/ACM模式如何构建二叉树.md)
* [解密互联网大厂研发流程](./problems/前序/互联网大厂研发流程.md)

* 工具
* [一站式vim配置](https://github.com/youngyangyang04/PowerVim)
* [保姆级Git入门教程,万字详解](https://mp.weixin.qq.com/s/Q_O0ey4C9tryPZaZeJocbA)
Expand All @@ -106,7 +94,6 @@
* [关于时间复杂度,你不知道的都在这里!](./problems/前序/关于时间复杂度,你不知道的都在这里!.md)
* [O(n)的算法居然超时了,此时的n究竟是多大?](./problems/前序/On的算法居然超时了,此时的n究竟是多大?.md)
* [通过一道面试题目,讲一讲递归算法的时间复杂度!](./problems/前序/通过一道面试题目,讲一讲递归算法的时间复杂度!.md)
* [本周小结!(算法性能分析系列一)](./problems/周总结/20201210复杂度分析周末总结.md)
* [关于空间复杂度,可能有几个疑问?](./problems/前序/关于空间复杂度,可能有几个疑问?.md)
* [递归算法的时间与空间复杂度分析!](./problems/前序/递归算法的时间与空间复杂度分析.md)
* [刷了这么多题,你了解自己代码的内存消耗么?](./problems/前序/刷了这么多题,你了解自己代码的内存消耗么?.md)
Expand Down Expand Up @@ -499,7 +486,7 @@

# 贡献者

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

# Star 趋势

Expand Down
Binary file modified pics/网站星球宣传海报.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions problems/0001.两数之和.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>


# 1. 两数之和
Expand Down Expand Up @@ -537,8 +537,8 @@ int* twoSum(int* nums, int numsSize, int target, int* returnSize){
return NULL;
}
```

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

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



Expand Down Expand Up @@ -677,8 +677,8 @@ public class Solution {
}
```


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

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



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

[力扣题目链接](https://leetcode.cn/problems/3sum/)
Expand Down Expand Up @@ -938,8 +936,8 @@ object Solution {
}
}
```

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

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


# 17.电话号码的字母组合
Expand Down Expand Up @@ -765,8 +765,8 @@ public class Solution
}
```


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

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


> 一样的道理,能解决四数之和
Expand Down Expand Up @@ -697,8 +697,8 @@ def four_sum(nums, target)
return result
end
```

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

4 changes: 2 additions & 2 deletions problems/0019.删除链表的倒数第N个节点.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>



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



Expand Down
38 changes: 35 additions & 3 deletions problems/0024.两两交换链表中的节点.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>


# 24. 两两交换链表中的节点
Expand Down Expand Up @@ -81,7 +81,7 @@ public:

上面的代码我第一次提交执行用时8ms,打败6.5%的用户,差点吓到我了。

心想应该没有更好的方法了吧,也就$O(n)$的时间复杂度,重复提交几次,这样了:
心想应该没有更好的方法了吧,也就 $O(n)$ 的时间复杂度,重复提交几次,这样了:

![24.两两交换链表中的节点](https://code-thinking.cdn.bcebos.com/pics/24.%E4%B8%A4%E4%B8%A4%E4%BA%A4%E6%8D%A2%E9%93%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9.png)

Expand Down Expand Up @@ -181,6 +181,23 @@ class Solution {
}
```

```java
// 将步骤 2,3 交换顺序,这样不用定义 temp 节点
public ListNode swapPairs(ListNode head) {
ListNode dummy = new ListNode(0, head);
ListNode cur = dummy;
while (cur.next != null && cur.next.next != null) {
ListNode node1 = cur.next;// 第 1 个节点
ListNode node2 = cur.next.next;// 第 2 个节点
cur.next = node2; // 步骤 1
node1.next = node2.next;// 步骤 3
node2.next = node1;// 步骤 2
cur = cur.next.next;
}
return dummy.next;
}
```

### Python:

```python
Expand Down Expand Up @@ -285,6 +302,21 @@ var swapPairs = function (head) {
};
```

```javascript
// 递归版本
var swapPairs = function (head) {
if (head == null || head.next == null) {
return head;
}

let after = head.next;
head.next = swapPairs(after.next);
after.next = head;

return after;
};
```

### TypeScript:

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


# 27. 移除元素
Expand Down
36 changes: 34 additions & 2 deletions problems/0028.实现strStr.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>


> 在一个串中查找是否出现过另一个串,这是KMP的看家本领。
Expand Down Expand Up @@ -564,6 +564,38 @@ public:
## 其他语言版本

### Java:
```Java
class Solution {
/**
牺牲空间,换取最直白的暴力法
时间复杂度 O(n * m)
空间 O(n + m)
*/
public int strStr(String haystack, String needle) {
// 获取 haystack 和 needle 的长度
int n = haystack.length(), m = needle.length();
// 将字符串转换为字符数组,方便索引操作
char[] s = haystack.toCharArray(), p = needle.toCharArray();

// 遍历 haystack 字符串
for (int i = 0; i < n - m + 1; i++) {
// 初始化匹配的指针
int a = i, b = 0;
// 循环检查 needle 是否在当前位置开始匹配
while (b < m && s[a] == p[b]) {
// 如果当前字符匹配,则移动指针
a++;
b++;
}
// 如果 b 等于 m,说明 needle 已经完全匹配,返回当前位置 i
if (b == m) return i;
}

// 如果遍历完毕仍未找到匹配的子串,则返回 -1
return -1;
}
}
```

```Java
class Solution {
Expand Down
6 changes: 3 additions & 3 deletions problems/0031.下一个排列.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<a href="https://programmercarl.com/other/xunlianying.html" target="_blank">
<a href="https://www.programmercarl.com/xunlian/xunlianying.html" target="_blank">
<img src="../pics/训练营.png" width="1000"/>
</a>
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
<p align="center"><strong><a href="./qita/join.md">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们受益!</strong></p>



Expand Down Expand Up @@ -268,8 +268,8 @@ var nextPermutation = function(nums) {
```



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

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


# 34. 在排序数组中查找元素的第一个和最后一个位置
Expand Down Expand Up @@ -854,8 +854,8 @@ int* searchRange(int* nums, int numsSize, int target, int* returnSize){
}
```
<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

0 comments on commit 49ae4d4

Please sign in to comment.