Trains the technique from
LeetCode 189Rotate ArrayThis 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 firmware ring buffer holds one signed sensor delta per slot in the integer array readings. Slot 0 is the oldest slot and the buffer wraps, so the slot after the last one is slot 0 again.
A technician wants the whole trace pushed later by delay slots: whatever sits in a slot ends up delay slots further along, and anything that runs off the end reappears at the front. The value of delay can be 0, and it can also be larger than the number of slots, in which case the trace simply wraps more than once.
Rearrange readings itself, using no more than a constant amount of extra space on top of the buffer, then return readings.
Example 1
Every delta moves one slot later and the 4 that fell off the end lands in slot 0.
Example 2
Five pushes across three slots is one full wrap plus two more, so the outcome matches a push of two.
Example 3
Nothing is pushed, so the buffer comes back exactly as it arrived.
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 delay_buffer(readings: list[int], delay: int) -> list[int]:public int[] delayBuffer(int[] readings, int delay)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.