public static void reorderList(ListNode head) {
        if(head == null || head.next == null || head.next.next == null) return;

        ListNode n = head;
        int len = 1;
        while(n.next != null){
            n = n.next;
            len++;
        }

        ListNode partition = head;
        for(int i = 0; i < len/2 - 1; i++) partition = partition.next;
        ListNode second = partition.next;
        partition.next = null;
        second = reverse(second);

        ListNode first = head;
        ListNode dummy = new ListNode(-1);
        while(first != null && second != null){
            dummy.next = first;
            first = first.next;
            dummy.next.next = second;
            second = second.next;
            dummy = dummy.next.next;
        }
        dummy.next = first == null ? second : first;
    }