All problems
0059EasyLinked ListRecursion

Rewind the Telemetry Chain

Tracked in this browser only
Write code

Trains the technique from

LeetCode 206Reverse Linked List

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A probe stores its telemetry as a one-way chain of frames: every frame carries a signed reading and a link to the frame recorded after it, and the final frame links to nothing.

Because the harness passes plain JSON, the chain reaches you as the array frames, holding the readings in order from the front frame to the last one. An empty array means the chain has no frames at all. Your answer must use the same shape: the readings of the rebuilt chain, front frame first.

Turn the chain around so the frame that was last becomes the front and every link points at the frame that used to precede it. Solve it the way the chain itself demands: rebuild the frames, then walk them once and redirect one link at a time, carrying the frame behind you as you go. Beyond the frames themselves and the array you return, only a fixed number of frame references may be held.

Examples

Example 1

Input
frames = [4, -1, 9, 9, -12]
Output
[-12, 9, 9, -1, 4]

The frame holding -12 was last, so it becomes the front, and the readings come back in the opposite order. Repeated readings keep both copies.

Example 2

Input
frames = [30, -30]
Output
[-30, 30]

With two frames the single link between them flips, so the second frame leads.

Example 3

Input
frames = [7]
Output
[7]

A lone frame has no link to redirect, so the chain comes back unchanged. A chain of zero frames likewise answers with an empty chain.

Constraints

  • 0 <= frames.length <= 5000
  • -5000 <= frames[i] <= 5000

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def rewind_telemetry_chain(frames: list[int]) -> list[int]:
Java
public int[] rewindTelemetryChain(int[] frames)
September 7
Apply