Skip to content

Commit e116943

Browse files
author
tony
committed
反向链表
1 parent 9a8df47 commit e116943

2 files changed

Lines changed: 106 additions & 1 deletion

File tree

Queue.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
## 队列
1+
![image](./img/timg.jpg)
2+
<br>
3+
4+
## 前言
5+
6+
本人平时学习及收集内容,欢迎参入一起讨论。
7+
8+
## 关于作者
9+
10+
一个工作八年的草根程序员。
11+
12+
## 内容
13+
14+
```
15+
16+
## 联系作者
17+
18+
<div align="center">
19+
<p>
20+
平凡世界,贵在坚持。
21+
</p>
22+
<img src="./img/contact.png" />
23+
</div>
24+
```

链表.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
![image](./img/timg.jpg)
2+
<br>
3+
4+
## 前言
5+
6+
本人平时学习及收集内容,欢迎参入一起讨论。
7+
8+
## 关于作者
9+
10+
一个工作八年的草根程序员。
11+
12+
## 内容
13+
14+
- 链表概念
15+
- 单向链表
16+
- 双向链表
17+
- 反向链表
18+
19+
### 链表概念
20+
21+
```
22+
23+
```
24+
25+
### 单向链表
26+
27+
```
28+
29+
```
30+
31+
### 双向链表
32+
33+
```
34+
35+
```
36+
37+
### 反向链表
38+
39+
```
40+
41+
/**
42+
* 节点定义
43+
*/
44+
class Node{
45+
constructor(value,next){
46+
this.value = value;
47+
this.next = next;
48+
}
49+
}
50+
51+
/**
52+
* 翻转链表
53+
* @param {Node} head 未翻转链表的头节点
54+
* @return {Node} 翻转链表后的头节点
55+
*/
56+
function reverseList(head){
57+
let node = head,
58+
pre = null;
59+
60+
while (node){
61+
let next = node.next;
62+
63+
node.next = pre;
64+
65+
pre = node;
66+
node = next;
67+
}
68+
69+
return pre;
70+
}
71+
72+
73+
```
74+
75+
## 联系作者
76+
77+
<div align="center">
78+
<p>
79+
平凡世界,贵在坚持。
80+
</p>
81+
<img src="./img/contact.png" />
82+
</div>

0 commit comments

Comments
 (0)