Leetcode 987 Solution

This article provides solution to leetcode question 987 (reveal-cards-in-increasing-order)

https://leetcode.com/problems/reveal-cards-in-increasing-order

Solution

class Solution: def deckRevealedIncreasing(self, deck: List[int]) -> List[int]: deck.sort()
new_deck = [] for card in reversed(deck): if len(new_deck) >= 2: new_deck.insert(0, new_deck.pop(-1)) new_deck.insert(0, card)
return new_deck