Skip to content

Practice Reveal Cards In Increasing Order

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#950
LeetCode Problem

Reveal Cards In Increasing Order

Problem Statement

Arrange the distinct values in deck so the following process reveals them in increasing order: reveal and remove the top card, then, if any cards remain, move the next top card to the bottom; repeat until empty. Return the initial arrangement with its top card at index 0.

Source: Reveal Cards In Increasing Order on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

Input
deck = [1,1000]
Output
[1,1000]

Constraints

1 <= deck.length <= 1000
1 <= deck[i] <= 10^6
All the values of deck are unique.

Related LeetCode Problems

Practice more problems similar to Reveal Cards In Increasing Order.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.