Code RoomReveal cards in order
MediumPrep Room Coding #245

Reveal cards in order

CodingAlgorithms & data structuresMid–Senior~20 min

There is a single-lane road simulated as a deque. You are given an ordered deck of distinct integer cards. Reveal them in increasing order using this process repeatedly on a queue: take the top card and reveal it, then if cards remain, move the next top card to the bottom of the queue. Given the deck size implicitly as a list of integers to reveal, return the ordering in which you must INITIALLY arrange the deck so that the above reveal process yields the cards in strictly increasing sorted order. The input list contains 1 to 1000 distinct integers.

Implement
deck_revealed_increasing(deck: list[int]) → list[int]
Examples
in[[17,13,11,2,3,5,7]]out[2,13,3,11,5,17,7]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 20 min
InputExpectedGot
[[17,13,11,2,3,5,7]][2,13,3,11,5,17,7]not run yetsample