17 · Queues & Deques

#950 Reveal Cards In Increasing Order

Mediumsolve on LeetCode ↗

frequently reported atGoogle

the problem

In plain words

You may order a deck of unique cards any way you like. Then you repeatedly reveal the top card and remove it; if cards remain, you move the next top card to the bottom. Return an ordering that reveals the cards in increasing order.

in deck = [17,13,11,2,3,5,7]

out [2,13,3,11,5,17,7]

Revealing gives 2, 3, 5, 7, 11, 13, 17.

  • 1 ≤ n ≤ 1000
  • 1 ≤ deck[i] ≤ 10⁶
  • All values are unique

your turn

Try it before you peek

Read the examples, say the brute force out loud, then write code: here or on LeetCode ↗. Stuck for 20 minutes? Open one hint at a time.

Solve it in the browser

LeetCode-style: complete the class. Compiled by the real javac (Java 17) and judged right here — nothing is sent anywhere.

    Solutions are hidden so you can try first. Even 20 minutes of real effort makes the answer stick far better than reading it.

    Marking the problem solved, or opening every hint, also shows it.

    practise next

    Similar problems

    1. #2073
    2. #225