反转链表 Posted on 2020-02-08 题目描述 输入一个链表,反转链表后,输出新链表的表头。 1234567891011121314151617public ListNode ReverseList(ListNode head) { if (head == null || head.next == null) { return head; } ListNode p = head; ListNode q = head.next; ListNode r; head.next = null; while (q != null) { r = q.next; q.next = p; p = q; q = r; } head = p; return head;}