Skip to content

Commit b594b1a

Browse files
author
laileon
committed
说明
1 parent fbdb6d2 commit b594b1a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/com/blankj/custom/structure/ListNode.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ public ListNode(int val, ListNode next) {
1818
public ListNode reverseList(ListNode head) {
1919
ListNode curr = null;
2020
while (head != null) { //如果当前节点不为空
21+
ListNode tmp = head.next; //tmp赋值为head后面的节点
2122
curr = head; //prev后移一位
22-
head = head.next;
23+
head = tmp; //head后移一位
2324
head.next = curr; //head指向head后面那个
24-
// ListNode tmp = head.next; //tmp赋值为head后面的节点
25-
// head = tmp; //head后移一位
2625
}
2726
return curr;
2827
}

0 commit comments

Comments
 (0)