from queue import Queue

class Solution:
    def deckRevealedIncreasing(self, deck):
        n = len(deck)
        que = Queue(maxsize=n)
        deck.sort()
        res = [0]*n
        for i in range(n):
            que.put(i)
        for i in range(n):
            index = que.get()
            val = deck[i]
            res[index]=val
            if not que.empty():
                que.put(que.get())
        return res

 

posted on 2018-12-13 20:54  Sempron2800+  阅读(132)  评论(0编辑  收藏  举报