Given a linked list L0 → L1 → … → Ln-1 → Ln, reorder it to L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → …
# Before: 1 → 2 → 3 → 4 → 5
# After: 1 → 5 → 2 → 4 → 3
This combines three classic techniques:
Time: O(n), Space: O(1). This problem tests whether you truly understand linked list manipulation.
📋 Instructions
Implement `reorder_list(head)` using the three-step approach.
Reorder [1,2,3,4,5] and print all values.
Step 1: Find middle with slow/fast. Step 2: Reverse the second half (from slow.next). Step 3: Merge first half and reversed second half by alternating nodes.