public ListNode ReverseList(ListNode head) {
        if (head == null || head.next == null){
            return head;
        }
        ListNode p  = head;
        ListNode q = new ListNode(-1);
        while (p != null){
            ListNode cur = p;
            p = p.next;
            cur.next = q.next;
            q.next = cur;
        }
        return q.next;
    }
 京公网安备 11010502036488号
京公网安备 11010502036488号