反转链表
public class ListNode{
ListNode next
= null
;
int value
;
public ListNode(int data
){
this.value
=data
;
}
}
public static void reverseList(ListNode head
){
ListNode pre
= null
;
ListNode temp
= null
;
while(head
!=null
){
temp
= head
.next
;
head
.next
=pre
;
pre
=head
;
head
=temp
;
}
return pre
;
}
转载请注明原文地址:https://blackberry.8miu.com/read-31776.html