950. Reveal Cards In Increasing Order

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 950

class Solution:
    def deckRevealedIncreasing(self, deck: List[int]) -> List[int]:
        q = deque()
        for v in sorted(deck, reverse=True):
            if q:
                q.appendleft(q.pop())
            q.appendleft(v)
        return list(q)