Reorder List

Reorder list to L0 → Ln → L1 → Ln-1 → ...

Pattern

Find Mid + Reverse + Merge

This problem follows the Find Mid + Reverse + Merge pattern, commonly found in the Linked List category. Recognizing this pattern is key to solving it efficiently in an interview setting.

Approach

How to Solve It

Find middle, reverse second half, merge the two halves alternately.

Key Insight

Three classic operations combined: find middle (fast/slow), reverse list (iterative), merge two lists (interleave). Master these individually.

Step-by-step

  1. 1Find the middle of the list using slow/fast pointers
  2. 2Reverse the second half of the list
  3. 3Merge the two halves by alternating nodes

Pseudocode

# Find middle
slow = fast = head
while fast.next and fast.next.next:
    slow = slow.next
    fast = fast.next.next
# Reverse second half
second = reverse(slow.next)
slow.next = null
# Merge alternating
first = head
while second:
    tmp1, tmp2 = first.next, second.next
    first.next = second
    second.next = tmp1
    first, second = tmp1, tmp2
Complexity Analysis

Time Complexity

O(n)

Space Complexity

O(1)
More Linked List Problems

Master this pattern with YeetCode

Practice Reorder List and similar Linked List problems with flashcards. Build pattern recognition through active recall.

Practice this problem