var reorderList = function (head) { let slow = head, fast = head; while (fast.next && fast.next.next) { slow = slow.next; fast = fast.next.next; } let second = slow.next; slow.next = null; let prev = null; while (second) { const next = second.next; second.next = prev; prev = second; second = next; } let first = head; second = prev; while (second) { const tmp1 = first.next, tmp2 = second.next; first.next = second; second.next = tmp1; first = tmp1; second = tmp2; } };