public ListNode reverseBetween(ListNode head, int m, int n) {
        if (head == null || m >= n)
            return head;
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        head = dummy;
        for (int i = 1; i < m; ++i) {
            if (head == null)
                return null;
            head = head.next;
        }
        ListNode preM = head;
        ListNode mNode = head.next, nNode = head.next;
        ListNode postnNode = head.next.next;
        for (int i = m; i < n; ++i) {
            if (postnNode == null)
                return null;
            ListNode temp = postnNode.next;
            postnNode.next = nNode;
            nNode = postnNode;
            postnNode = temp;
        }
        mNode.next = postnNode;
        preM.next = nNode;
        return dummy.next;
    }