Leetcode 987 Solution
This article provides solution to leetcode question 987 (reveal-cards-in-increasing-order)
Access this page by simply typing in "lcs 987" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
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