public void reorderList(ListNode head) {

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

        //use the slow and fast, to divide the list into two parts
        ListNode slow = head;
        ListNode fast = head;
        while (fast != null && fast.getNext() != null) {
            slow = slow.getNext();
            fast = fast.getNext().getNext();
        }

        ListNode secondHead = slow.getNext();
        //avoid loop
        slow.setNext(null);
        secondHead = reverse(secondHead);
        ListNode current = head;
        //link the two parts together
        while (secondHead != null) {
            ListNode temp = secondHead.getNext();
            secondHead.setNext(current.getNext());
            current.setNext(secondHead);
            current = current.getNext().getNext();
            secondHead = temp;
        }
    }