public class Solution {
public ListNode ReverseList(ListNode head) {
ListNode pre=null;
ListNode next=null;
if(head==null)return null;
while(head!=null)
{
next=head.next;
head.next=pre;
pre=head;
head=next;
}
return pre ;
}
}
输入一个链表,反转链表后,输出链表的所有元素。
最新推荐文章于 2022-07-20 22:36:12 发布