本文共 438 字,大约阅读时间需要 1 分钟。
输入一个链表,反转链表后,输出新链表的表头。
public class Solution { public ListNode ReverseList(ListNode head) { ListNode pHead=head; if(head==null) return null; ListNode second=pHead.next; ListNode three=null; pHead.next=null; while(second!=null){ three=second.next; second.next=pHead; pHead=second; second=three; } return pHead; }}
转载地址:http://oasa.baihongyu.com/