mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-28 19:43:31 +08:00
c++
This commit is contained in:
parent
97273a3fc5
commit
0b6c86661b
@ -17,7 +17,7 @@ This article offers a sample of basic Markdown.
|
||||
|
||||
# 正文开始
|
||||
|
||||
# 1.41. 包含min函数的栈
|
||||
## 1.41. 包含min函数的栈
|
||||
|
||||
```cpp
|
||||
//https://leetcode.cn/problems/bao-han-minhan-shu-de-zhan-lcof/description/
|
||||
@ -64,7 +64,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 2.35. 反转链表
|
||||
## 2.35. 反转链表
|
||||
|
||||
```cpp
|
||||
/**
|
||||
@ -88,7 +88,7 @@ public:
|
||||
|
||||

|
||||
|
||||
# 3.19. 二叉树的下一个节点
|
||||
## 3.19. 二叉树的下一个节点
|
||||
|
||||
```cpp
|
||||
/**
|
||||
@ -115,7 +115,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 4.34. 链表中环的入口结点
|
||||
## 4.34. 链表中环的入口结点
|
||||
|
||||
[142. 环形链表 II](https://leetcode.cn/problems/linked-list-cycle-ii/)
|
||||
|
||||
@ -170,7 +170,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 5.77.翻转单词顺序
|
||||
## 5.77.翻转单词顺序
|
||||
|
||||
[151. 反转字符串中的单词](https://leetcode.cn/problems/reverse-words-in-a-string/)
|
||||
|
||||
@ -196,7 +196,7 @@ reverse(s.begin()+0,s.begin()+s.size());//范围:[)
|
||||
|
||||
|
||||
|
||||
# 6.18.重建二叉树
|
||||
## 6.18.重建二叉树
|
||||
|
||||
https://leetcode.cn/problems/zhong-jian-er-cha-shu-lcof/description/
|
||||
|
||||
@ -240,7 +240,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 7.21. 斐波那契数列
|
||||
## 7.21. 斐波那契数列
|
||||
|
||||
```cpp
|
||||
//f[i] = f[i-1]+f[i-2]
|
||||
@ -252,7 +252,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 8.78. 左旋转字符串
|
||||
## 8.78. 左旋转字符串
|
||||
|
||||
```cpp
|
||||
//先把整个进行翻转
|
||||
@ -265,7 +265,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 9.87. 把字符串转换成整数
|
||||
## 9.87. 把字符串转换成整数
|
||||
|
||||
```cpp
|
||||
//分步
|
||||
@ -281,7 +281,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 10.28. 在O(1)时间删除链表结点
|
||||
## 10.28. 在O(1)时间删除链表结点
|
||||
|
||||
```cpp
|
||||
/**
|
||||
@ -302,7 +302,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 11.66. 两个链表的第一个公共结点
|
||||
## 11.66. 两个链表的第一个公共结点
|
||||
|
||||
```cpp
|
||||
/**
|
||||
@ -332,7 +332,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 12.84. 求1+2+…+n
|
||||
## 12.84. 求1+2+…+n
|
||||
|
||||
```cpp
|
||||
//语法题:(false && 条件); = false 可以起到if的效果
|
||||
@ -344,7 +344,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 13.36. 合并两个排序的链表
|
||||
## 13.36. 合并两个排序的链表
|
||||
|
||||
```cpp
|
||||
/**
|
||||
@ -369,7 +369,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 14.14. 不修改数组找出重复的数字
|
||||
## 14.14. 不修改数组找出重复的数字
|
||||
|
||||
```cpp
|
||||
//简单方法:哈希表
|
||||
@ -401,7 +401,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 15.68. 0到n-1中缺失的数字
|
||||
## 15.68. 0到n-1中缺失的数字
|
||||
|
||||
```cpp
|
||||
//二分
|
||||
@ -416,7 +416,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
## 补充:13. 找出数组中重复的数字
|
||||
### 补充:13. 找出数组中重复的数字
|
||||
|
||||
```cpp
|
||||
//哈希表秒了
|
||||
@ -431,7 +431,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 16.75. 和为S的两个数字
|
||||
## 16.75. 和为S的两个数字
|
||||
|
||||
```cpp
|
||||
//时间复杂度最重要
|
||||
@ -444,7 +444,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 17.23. 矩阵中的路径
|
||||
## 17.23. 矩阵中的路径
|
||||
|
||||
```cpp
|
||||
//dfs
|
||||
@ -493,7 +493,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 18.55. 连续子数组的最大和
|
||||
## 18.55. 连续子数组的最大和
|
||||
|
||||
```cpp
|
||||
s表示收益
|
||||
@ -502,7 +502,7 @@ res表示最终结果
|
||||
|
||||

|
||||
|
||||
# 19.42. 栈的压入、弹出序列
|
||||
## 19.42. 栈的压入、弹出序列
|
||||
|
||||
```cpp
|
||||
关键:不是所有的数都入栈,他才开始进行弹出操作.
|
||||
@ -523,7 +523,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 20.70. 二叉搜索树的第k个结点
|
||||
## 20.70. 二叉搜索树的第k个结点
|
||||
|
||||
[230. 二叉搜索树中第K小的元素](https://leetcode.cn/problems/kth-smallest-element-in-a-bst/)
|
||||
|
||||
@ -552,7 +552,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 21.48. 复杂链表的复刻
|
||||
## 21.48. 复杂链表的复刻
|
||||
|
||||
```cpp
|
||||
//1.给旧链表每2个节点之间加1个节点(新节点的值是前节点的值)
|
||||
@ -586,7 +586,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 22.53. 最小的k个数
|
||||
## 22.53. 最小的k个数
|
||||
|
||||

|
||||
|
||||
@ -617,7 +617,7 @@ public:
|
||||
|
||||
|
||||
|
||||
# 23.33. 链表中倒数第k个节点
|
||||
## 23.33. 链表中倒数第k个节点
|
||||
|
||||
```cpp
|
||||
//先求链表长度n
|
||||
@ -641,7 +641,7 @@ public:
|
||||
|
||||

|
||||
|
||||
# 24.71. 二叉树的深度
|
||||
## 24.71. 二叉树的深度
|
||||
|
||||
```cpp
|
||||
//max(左子树,右子树)+1
|
||||
@ -665,7 +665,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 25.72. 平衡二叉树
|
||||
## 25.72. 平衡二叉树
|
||||
|
||||
```cpp
|
||||
//这个题和求树的最大深度一样
|
||||
@ -689,7 +689,7 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
# 26.15. 二维数组中的查找
|
||||
## 26.15. 二维数组中的查找
|
||||
|
||||
```cpp
|
||||
//每列是递增的
|
||||
|
Loading…
Reference in New Issue
Block a user