cards of even length. Masha and Pete play in rounds. In each round Masha first takes the card with the smallest number, then Pete does the same among the cards that are left.
Then both put their cards on a shared pile: Pete first, Masha second. The game goes on while cards remain on the table.
Return the numbers on the pile in the order the cards were placed.cards=[7, 3, 9, 1] → [3, 1, 9, 7]
Round one: Masha takes 1, Pete takes 3; the pile gets 3, then 1. Round two: 7 and 9, so the pile gets 9, then 7.
cards=[4, 4] → [4, 4]
Both cards are equal, so the swap changes nothing.
cards=[7, 3, 9, 1]
[3, 1, 9, 7]
Run checks the first 3 tests in your browser. Submit checks all 89 tests on the server, hidden ones included.