Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Reveal Cards In Increasing Order
Bookmark
Brute Force
Queue Simulation
Reverse Simulation
Input
Example 1
Sequential
Two Cards
Reverse Order
Custom
deck
=
[17, 13, 11, 2, 3, 5, 7]
deck
17
13
11
2
3
5
7
try every start order; the reveal must come out sorted
deck
17
13
11
2
3
5
7
try every start order; the reveal must come out sorted
attempt #1
target (sorted)
2
3
5
7
11
13
17
start order
17
13
11
2
3
5
7
simulate the reveal on this order…
attempt #2
target (sorted)
2
3
5
7
11
13
17
start order
17
13
11
2
3
7
5
simulate the reveal on this order…
attempt #3
target (sorted)
2
3
5
7
11
13
17
start order
17
13
11
2
5
3
7
simulate the reveal on this order…
attempt #4
target (sorted)
2
3
5
7
11
13
17
start order
17
13
11
2
5
7
3
simulate the reveal on this order…
attempt #5
target (sorted)
2
3
5
7
11
13
17
start order
17
13
11
2
7
3
5
simulate the reveal on this order…
attempt #6
target (sorted)
2
3
5
7
11
13
17
start order
17
13
11
2
7
5
3
simulate the reveal on this order…
target (sorted)
2
3
5
7
11
13
17
searching more permutations…
2337
permutation(s) checked… continuing the search
reveal = target ✓
target (sorted)
2
3
5
7
11
13
17
start order
2
13
3
11
5
17
7
reveal (simulated)
2
3
5
7
11
13
17
this order reveals in increasing order!
target (sorted)
2
3
5
7
11
13
17
answer =
[2, 13, 3, 11, 5, 17, 7]
algo
master
.
io
Step:
Brute force: try every starting order and simulate the reveal.
0 / 18
Input
Example 1
Sequential
Two Cards
Reverse Order
Custom
deck
=
[17, 13, 11, 2, 3, 5, 7]
0 / 18
algo
master
.
io
Step:
Brute force: try every starting order and simulate the reveal.