Standard Bar Linked List · Medium Problems of LL O(N) · O(1)
A one-way relay line must suddenly run in reverse — every worker's outbound link is re-aimed at the person who used to point at them, and the last worker becomes the new starter. Each rewiring happens one worker at a time while walking the line, and nobody may lose track of the worker ahead while their own link is being flipped.
Input: An array head of node values representing the linked list.
Output: The values of the reversed list, read from the new head.
0 <= list length <= 10^5-10^9 <= node value <= 10^9Input: {"head":[1,2,3,4,5]}
Output: [5,4,3,2,1]
Every link flips and the tail node 5 opens the reversed chain.
Input: {"head":[1,2]}
Output: [2,1]
A two-node chain needs exactly one link flip.