思想:将节点一个个插入到前一个节点前面。
public class Solution {
public ListNode reverseList(ListNode head) {
if(head==null) return head;
ListNode t=null,q;
while(head.next!=null)
{
q=head.next;
head.next=t;
t=head;
head=q;
}
head.next=t;
return head;
}
}