Baseline Linked List · Doubly Linked List O(n) · O(1)
A plant repurposes a conveyor whose stations are two-way linked, and the retrofit requires the line to run in the opposite direction. Each station's forward and backward rails swap roles, and the station that used to hand work off into nowhere becomes the new entry point. Report the station order from the new entry.
Input: An array arr of n node values representing the doubly linked list.
Output: The list after reversal, read from the new head.
1 <= n <= 10^5-10^9 <= arr[i] <= 10^9Input: {"arr":[3,4,5]}
Output: [5,4,3]
The line's exit station (5) becomes its entry.
Input: {"arr":[75,122,59,196]}
Output: [196,59,122,75]
Four stations, every rail pair swapped, new order starts at 196.