Interview Questions/Coding/Swap Contest Scoreboards

Swap Contest Scoreboards

Preview mode. Log in to edit, run, submit, and save progress.

Easy

Swap Contest Scoreboards

Two contest objects store their scoreboards as lists of integers. You are given the initial scores for both contests. Create one Contest object for each scoreboard, swap the score lists stored inside the two objects, and return the scoreboards after the swap. The first output line should contain the scores now stored in the first contest, and the second output line should contain the scores now stored in the second contest.

Examples

Example 1
Input:
10 20 30
5 15
Output:
5 15

Explanation: After swapping, the first contest stores the second list and the second contest stores the first list.

Approach hint

Create two Contest objects first, one from each input list.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp