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 fbdb6d2 commit b594b1aCopy full SHA for b594b1a
src/com/blankj/custom/structure/ListNode.java
@@ -18,11 +18,10 @@ public ListNode(int val, ListNode next) {
18
public ListNode reverseList(ListNode head) {
19
ListNode curr = null;
20
while (head != null) { //如果当前节点不为空
21
+ ListNode tmp = head.next; //tmp赋值为head后面的节点
22
curr = head; //prev后移一位
- head = head.next;
23
+ head = tmp; //head后移一位
24
head.next = curr; //head指向head后面那个
-// ListNode tmp = head.next; //tmp赋值为head后面的节点
25
-// head = tmp; //head后移一位
26
}
27
return curr;
28
0 commit comments