Example — even length
Input
[1, 2, 3, 4]
Output
[1, 4, 2, 3]
After reordering: first (1), last (4), second (2), second-last (3).
Full lesson preview
Reorder a singly linked list so nodes alternate from the start and end: L0 → Ln → L1 → Ln-1 → ...
Problem statement
Task
Examples
Input
[1, 2, 3, 4]
Output
[1, 4, 2, 3]
After reordering: first (1), last (4), second (2), second-last (3).
Input format
Output format
Constraints
Samples
Input
[1, 2, 3, 4, 5]
Output
[1, 5, 2, 4, 3]
Interleave nodes from the start and end.