File tree Expand file tree Collapse file tree 8 files changed +30
-30
lines changed Expand file tree Collapse file tree 8 files changed +30
-30
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,6 @@ char[] chars = s.toCharArray();
20
20
Pattern . matchs() // 字符串匹配
21
21
```
22
22
23
-
24
-
25
23
### 动态规划
26
24
27
25
** 第一步骤** :定义** 数组元素的含义** ,我们会用一个数组,来保存历史数组,假设用一维数组 dp[ ] 吧。这个时候有一个非常非常重要的点,就是规定你这个数组元素的含义,例如你的 dp[ i] 是代表什么意思。
Original file line number Diff line number Diff line change 1
- ### 二分搜索
1
+ ## 二分搜索
2
2
3
- #### 二分搜索模板
3
+ ### 二分搜索模板
4
4
5
5
给一个** 有序数组** 和目标值,找第一次/最后一次/任何一次出现的索引,如果没有出现返回 -1
6
6
Original file line number Diff line number Diff line change 1
- ### 动态规划
1
+ # 动态规划
2
2
3
- #### 背景
3
+ ## 背景
4
4
5
5
先从一道题目开始~
6
6
Original file line number Diff line number Diff line change 1
- ### 二叉树
1
+ ## 二叉树
2
2
3
- #### 二叉树遍历
3
+ ### 二叉树遍历
4
4
5
5
** 前序遍历** :** 先访问根节点** ,再前序遍历左子树,再前序遍历右子树 ** 中序遍历** :先中序遍历左子树,** 再访问根节点** ,再中序遍历右子树 ** 后序遍历** :先后序遍历左子树,再后序遍历右子树,** 再访问根节点** 。
6
6
Original file line number Diff line number Diff line change 1
- ### 二进制
1
+ ## 二进制
2
2
3
3
JS二进制基础知识: [ 二进制] ( https://wangdoc.com/javascript/operators/bit.html )
4
4
Original file line number Diff line number Diff line change 1
- ### 栈和队列
1
+ ## 栈和队列
2
2
3
- #### 简介
3
+ ### 简介
4
4
5
5
栈的特点是后入先出,根据这个特点可以临时保存一些数据,之后用到依次再弹出来,常用于 DFS 深度搜索
6
6
7
7
队列一般常用于 BFS 广度搜索,类似一层一层的搜索。
8
8
9
- #### Stack 栈
9
+ ### Stack 栈
10
10
11
11
##### 155.最小栈 [ min-stack] ( https://leetcode-cn.com/problems/min-stack/ )
12
12
Original file line number Diff line number Diff line change 1
- ### 链表
1
+ ## 链表
2
2
3
- #### 核心点
3
+ ### 核心点
4
4
5
5
- null/nil 异常处理
6
6
- dummy node 哑巴节点
11
11
- 合并两个链表
12
12
- 找到链表的中间节点
13
13
14
- #### 练习
15
-
16
- ##### 83.删除排序链表中的重复元素 [ remove-duplicates-from-sorted-list] ( https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/ )
17
-
18
- > 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。
14
+ ** 链表的数据结构**
19
15
20
16
``` js
21
17
/**
22
18
* Definition for singly-linked list.
23
- * function ListNode(val) {
24
- * this.val = val;
25
- * this.next = null;
26
- * }
27
19
*/
20
+ function ListNode (val ) {
21
+ this .val = val;
22
+ this .next = null ;
23
+ }
24
+ ```
25
+
26
+ ### 练习
28
27
28
+ ##### 83.删除排序链表中的重复元素 [ remove-duplicates-from-sorted-list] ( https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/ )
29
+
30
+ > 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。
31
+
32
+ ``` js
29
33
var deleteDuplicates = function (head ) {
30
34
let current = head;
31
35
while (current !== null && current .next !== null ){
@@ -39,10 +43,8 @@ var deleteDuplicates = function(head) {
39
43
};
40
44
```
41
45
42
- 递归写法
43
-
44
46
``` js
45
- var deleteDuplicates = function (head ) {
47
+ var deleteDuplicates = function (head ) { // 递归写法
46
48
if (head === null || head .next === null ){
47
49
return head;
48
50
}
@@ -69,7 +71,7 @@ var deleteDuplicates = function(head) {
69
71
front = front .next ;
70
72
back = back .next ;
71
73
} else {
72
- while (back!== null && front .next .val === back .val ){
74
+ while (back !== null && front .next .val === back .val ){
73
75
back = back .next ;
74
76
}
75
77
front .next = back;
Original file line number Diff line number Diff line change 1
- ### 递归
1
+ ## 递归
2
2
3
- #### 介绍
3
+ ### 介绍
4
4
5
5
将大问题转化为小问题,通过递归依次解决各个小问题。
6
6
7
- #### 示例
7
+ ### 示例
8
8
9
9
##### 334.反转字符串 [ reverse-string] ( https://leetcode-cn.com/problems/reverse-string/ )
10
10
You can’t perform that action at this time.
0 commit comments