Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Deque Lab
Linear Data Structures
Concept shape
Core
0
1
2
3
4
5
Definition
A deque supports adding and removing from both ends.
Step 1 / 5
Concept shape
Linear Data Structures Core
Deque
Welcome to the Deque concept lab. A deque supports adding and removing from both ends. The must know points are: Can behave as a stack or queue. Useful for window problems. Both ends should be O(1). The common operations are: pushFront O(1), pushBack O(1), popFront O(1), popBack O(1). The complexity shape is Core operations O(1). Watch out for these pitfalls: Implementing with an array API that makes front operations O(n). Related algorithms include Sliding Window Maximum, BFS.
Concept details
A deque supports adding and removing from both ends.
Must know
- Can behave as a stack or queue.
- Useful for window problems.
- Both ends should be O(1).
Complexity
Core operations O(1)
1.0x