Show problems as
Classic problem #1929EasyArraySimulation

Concatenation of Array

Real-world version: Two Cycle Playout
Tracked in this browser only
Read Concatenation of Array on LeetCode(opens in a new tab)

The statement here is our own: the same inputs, outputs and technique.

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 starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.

Python
def two_cycle_playout(clips: list[int]) -> list[int]:
Java
public int[] twoCyclePlayout(int[] clips)