//链表逆序
public ListNode reverseList(ListNode head)
{
if(head == null || head.next == null)
return head;
ListNode pre = head;
ListNode cur = head.next;
while(cur != null)
{
ListNode temp = cur.next;
cur.next = pre;
pre = cur;
cur = temp;
}
head.next = null;
return head;
}
class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
next = null;
}
}