Reorder List

Reorder L0 → L1 → … → Ln into L0 → Ln → L1 → Ln−1 → L2 → … in place.

A way to picture it

You're shuffling a deck with a riffle, but one half is upside down. Cut the deck in the middle, flip the bottom half over, then interleave: one card from the top half, one from the flipped half, and repeat.

How to approach it

Three classics chained together: find the middle (slow/fast), reverse the second half, then merge the halves alternately.

Example

Input: {"head":[1,2,3,4]}. Output: [1,4,2,3].

Complexity: O(n) time and O(1) space. Three linear passes, all rewiring in place.

This page includes an animated walkthrough, Java and Python solutions, and a question to check your understanding.