All problems
0122EasyArraySimulation

Two Cycle Playout

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1929Concatenation of Array

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 stadium ribbon screen fills each break by running its clip roster through twice, back to back. The roster arrives as the array clips, holding clip ids in the order the operator queued them.

Return the full playout order for one break. If the roster holds n clips, the answer has length 2 * n: slot i plays clips[i], and slot i + n plays clips[i] again. The roster is queued as-is, so a clip listed twice plays in both of its slots on each cycle, and the second cycle runs forward in the same direction as the first.

Examples

Example 1

Input
clips = [7, 4, 9]
Output
[7, 4, 9, 7, 4, 9]

Three clips fill six slots. The second cycle repeats the roster in its original direction, so slot 3 replays the clip from slot 0.

Example 2

Input
clips = [12, 12]
Output
[12, 12, 12, 12]

The operator queued the same clip twice, and both entries survive into both cycles, giving four slots.

Example 3

Input
clips = [5]
Output
[5, 5]

A one-clip roster fills a two-slot break.

Constraints

  • n == clips.length
  • 1 <= n <= 1000
  • 1 <= clips[i] <= 1000

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 two_cycle_playout(clips: list[int]) -> list[int]:
Java
public int[] twoCyclePlayout(int[] clips)
September 7
Apply