Trains the technique from
LeetCode 61Rotate ListThis 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 radio show keeps its rundown as a one-way chain of cue cards. Each card carries a signed timing offset in seconds and a link to the card that comes after it, and the final card links to nothing.
Because the harness passes plain JSON, the chain reaches you as the array cues, listing the offsets from the leading card through to the final one. An empty array means there is no rundown at all. Your answer must come back in the same shape: the offsets of the rearranged chain, leading card first.
The producer wants the rundown wound forward by shift places. One place forward means the final card becomes the leader and everything else slides back one spot; shift places forward means the last shift cards move ahead of the rest as a block, with their own order among themselves untouched. The value of shift can run far past the number of cards, in which case the winding simply comes around the chain again as many times as it needs to. A rundown of no cards, or of one card, comes back exactly as it arrived.
Do the work the chain calls for: hold the rundown as linked cards and move cards by changing which card each one links to. Do not build the answer by sorting the offsets or by pasting slices of the array together.
Example 1
Winding forward twice moves the final two cards, holding 4 and -7 in that order, ahead of the other three.
Example 2
Seven places around a chain of three cards is two full laps plus one more place, so only the final card ends up in front.
Example 3
There are no cards to wind, so the rundown stays empty however large the shift is.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def rundown_cue_shift(cues: list[int], shift: int) -> list[int]:public int[] rundownCueShift(int[] cues, int shift)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.