public static class ListNode {
int val;
ListNode next = null;
ListNode(int val) {
this.val = val;
}
}
public ListNode ReverseList(ListNode head) {
ListNode p1=null;
ListNode p2=null;
while (head!=null){
p2=head.next;
head.next=p1;
p1=head;
head=p2;
}
return p1;
}
链表反转
最新推荐文章于 2024-11-11 21:19:25 发布