We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d7d0445 commit 24982abCopy full SHA for 24982ab
problems/206.reverse-linked-list.md
@@ -193,3 +193,24 @@ public:
193
}
194
};
195
```
196
+
197
+### JavaScript实现
198
+```javascript
199
+var reverseList = function(head) {
200
+ // 递归结束条件
201
+ if (head === null || head.next === null) {
202
+ return head
203
+ }
204
205
+ // 递归反转 子链表
206
+ let newReverseList = reverseList(head.next)
207
+ // 获取原来链表的第2个节点newReverseListTail
208
+ let newReverseListTail = head.next
209
+ // 调整原来头结点和第2个节点的指向
210
+ newReverseListTail.next = head
211
+ head.next = null
212
213
+ // 将调整后的链表返回
214
+ return newReverseList
215
+}
216
+```
0 commit comments