Code Room
CodingMediumcod-g108
Subject DequeLevel Mid–Senior~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.