Concatenation of Array
Real-world version: Two Cycle PlayoutThe 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.
def two_cycle_playout(clips: list[int]) -> list[int]:public int[] twoCyclePlayout(int[] clips)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 8 test cases: 8 passed
- Passed: 3 worked examples confirmed by running the code
- Passed: 0 eight-word sequences shared with the parent problem's text
- Passed: Agrees with an independent brute-force solution on random inputs
- Passed: Test set shown to catch deliberately broken solutions
- Passed: Reviewed by a separate quality pass
- Passed: Function arity matches the parent problem's
More on the same topics
- Reshape the MatrixReal-world version: Relaying the Contact SheetEasy
- Separate the Digits in an ArrayReal-world version: Digit Cells for the Ticket CodesEasy
- Distribute Elements Into Two Arrays IReal-world version: Splitting Parcels Onto Two Intake TraysEasy
- Transpose MatrixReal-world version: Flip a Reading Grid Onto Its SideEasy