public ListNode reverseBetween(ListNode head, int m, int n) {

        if (head == null || head.getNext() == null || m == n) {
            return head;
        }

        //create a preHead to comtrol the head node
        ListNode preHead = new ListNode(0);
        preHead.setNext(head);
        head = preHead;

        //before m, one node links by one
        ListNode n1 = head;
        int k = m - 1;
        while (k > 0) {
            n1 = n1.getNext();
            k--;
        }

        //between m and n, reverse
        preHead = n1;
        n1 = n1.getNext();
        k = n - m;
        /**
         * preHead -> 3,4,5,6 ->7
         * preHead -> 4,3,5,6 ->7
         * preHead -> 5,4,3,6 ->7
         * preHead -> 6,5,4,3 ->7
         */
        while (n1.getNext() != null && k > 0) {
            //move the next "one"
            ListNode temp = n1.getNext();
            //link to the next.next
            n1.setNext(temp.getNext());
            //link to the head of the reverse
            temp.setNext(preHead.getNext());
            //link to the "one"
            preHead.setNext(temp);
            k--;
        }
        return head.getNext();
    }