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 6806ce5 commit 95abdbfCopy full SHA for 95abdbf
206.反转链表.js
@@ -0,0 +1,35 @@
1
+/*
2
+ * @lc app=leetcode.cn id=206 lang=javascript
3
+ *
4
+ * [206] 反转链表
5
+ */
6
+
7
+// @lc code=start
8
+/**
9
+ * Definition for singly-linked list.
10
+ * function ListNode(val) {
11
+ * this.val = val;
12
+ * this.next = null;
13
+ * }
14
15
16
+ * @param {ListNode} head
17
+ * @return {ListNode}
18
19
+var reverseList = function(head) {
20
+ if (!head) {
21
+ return null;
22
+ }
23
24
+ let result = head;
25
+ head = head.next;
26
+ result.next = null;
27
+ while (head) {
28
+ const next = head.next;
29
+ head.next = result;
30
+ result = head;
31
+ head = next;
32
33
+ return result;
34
+};
35
+// @lc code=end
0 commit comments