输入一个链表,反转链表后,输出链表的所有元素。

来源:互联网 发布:linux shutdown now 编辑:程序博客网 时间:2024/05/29 02:21
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 ;    }}

阅读全文
0 0
原创粉丝点击