Skip to content

Commit 4901165

Browse files
committed
206
1 parent 14ce9cd commit 4901165

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

206.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* function ListNode(val) {
4+
* this.val = val;
5+
* this.next = null;
6+
* }
7+
*/
8+
/**
9+
* @param {ListNode} head
10+
* @return {ListNode}
11+
*/
12+
var reverseList = function(head) {
13+
var prev = null,
14+
next = null;
15+
while(head !== null){
16+
next = head.next;
17+
head.next = prev;
18+
prev = head;
19+
head = next;
20+
}
21+
return prev;
22+
};

0 commit comments

Comments
 (0)