> ## Content Index
> Fetch the complete content index at: https://andybase.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# 950 Reveal Cards In Increasing Order
- URL: https://andybase.com/950-reveal-cards-in-increasing-order/
- Published: 2018-12-06T21:35:50.000Z
- Updated: 2018-12-06T21:35:50.000Z
- Author: andy
- Tags: leetcode, contest, #Migrated-1784083136856, #wp, #wp-post, #Import 2026-07-15 02:38

link: [https://leetcode.com/problems/reveal-cards-in-increasing-order/](https://leetcode.com/problems/reveal-cards-in-increasing-order/?ref=andybase.com)

## Thought

So the rule is if you pop anything from front, then you shall move next head to tail. Reversely, if we want to build the original sequence, we could assume if you want to insert anything in head, you should pop your tail, and push the tail to head

## Code

```
class Solution:
    def deckRevealedIncreasing(self, deck):
        """
        :type deck: List[int]
        :rtype: List[int]
        """
        deck.sort(reverse= True)
        res = collections.deque()
        for i in deck:
            if not res:
                res.append(i)
            else:
                p = res[-1]
                res.pop()
                res.appendleft(p)
                res.appendleft(i)
        return list(res)
            
```

## Runtime

Time: O(n)  
Space: O(n)