FreeCareerPath
Build the PrimitiveMedium

Reorder List

Write `reorder_list(head)` reordering the list in place to `first, last, second, second-last, ...`. Return nothing; modify the nodes. [1,2,3,4] -> [1,4,2,3] [1,2,3,4,5] -> [1,5,2,4,3] This is three problems you already know, in sequence: find the middle with slow and fast pointers, reverse the second half, then interleave the two halves. Terminate the first half before reversing, or the interleave loops forever.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Reorder List" are saved to your account — logging in takes a few seconds.

Reorder List — FreeCareerPath