Deque

Replaces Stack, Queue, and LinkedList

O(1)

Python

One data structure to rule them all. A Deque (pronounced "Deck") is a double-ended queue that can add or remove elements from both ends in amortized constant time O(1). This allows us to replace Stack, Queue, and LinkedList with just four interfaces:

· addFirst()
· addLast()
· removeFirst()
· removeLast()

LeetCode

103. Binary Tree Zigzag Level Order Traversal

Python | Java

Previous
Previous

Leftmost Binary Search

Next
Next

String Builder