DSA AnimatorDSA animations
Reorder List LC #143 Medium Linked List · 3-Phase
Problem

You are given the head of a singly linked-list: L₀ → L₁ → … → Lₙ₋₁ → Lₙ. Reorder it to: L₀ → Lₙ → L₁ → Lₙ₋₁ → L₂ → Lₙ₋₂ → …. You may not modify the values in the list's nodes — only the nodes themselves may be changed.

Example 1
Input: [1,2,3,4]
Output: [1,4,2,3]
Example 2
Input: [1,2,3,4,5]
Output: [1,5,2,4,3]
Constraints: 1 ≤ n ≤ 5×10⁴  |  1 ≤ Node.val ≤ 1000
Try Examples
Custom:
List Visualization
 Phase 1 — Find Middle
State Variables
Phase
—
Head Ptr (l1)
—
Tail Ptr (l2)
—
Step Logic
Press ▶ Play or Next Step to begin the animation.
🎉
Ready
0 / 0
Select an example above and press Play.
Algorithm
1
Phase 1: Use slow/fast pointers to find the middle node
2
Phase 2: Reverse the second half (slow.next … end)
3
Phase 3: Interleave l1 and l2 by rewiring .next pointers
4
Done — list is reordered in-place, O(n) time O(1) space
Time
O(n)
Space
O(1)
Why It Works

Finding the middle splits the list into two halves of equal (or near-equal) length. Reversing the second half lets us pair elements from both ends simultaneously. The interleave step then weaves them together by advancing one pointer from the front and one from the back, alternating which chain we stitch in each iteration — producing exactly the required ordering without any extra memory.

How to solve Reorder List

LeetCode 143 · Medium · Linked List · Pattern: Fast & Slow + Reverse + Merge

Why the obvious approach is slow

Putting the nodes in an array and picking from both ends uses O(n) space. We can do it with three in-place steps.

The key idea

Find the middle with fast and slow pointers, and cut the list there. Reverse the second half. Merge the two halves by taking one node from each, alternately.

Remember

Split, reverse, merge. The same building blocks as the palindrome check.

Run the animation above on your own input, or watch the 1:05 video explanation of Reorder List with a dry run and Java code.

More Linked List problems