Tags

Deque

Deque

1 lesson
1 problem
1 question bank
1 community item

deque

Data Structures

1 lesson

Queue & Deque

Free
Beginner

45 min

1 prereq

BFS visits a graph one frontier at a time, and the trick that makes that work is a queue: nodes are added in the order they are discovered and pulled out in the same order, level by level. **Queue & Deque** captures that First In, First Out discipline as a reusable abstraction, then extends it to a double-ended variant that pops up surprisingly often in sliding-window problems. In this lesson, you will implement `enqueue`, `dequeue`, `front`, and `isEmpty` using both a linked list and an array, then see why a naive array queue wastes space and how a circular queue with two index pointers fixes that with `O(1)` operations. You will also build a deque that supports inserts and removes at both ends, the structure underneath the monotonic-deque pattern that solves sliding-window-maximum in linear time. In **Stack (LIFO)**, you implemented `push` and `pop` from the same end and saw how the choice of array versus linked list affected the worst-case bound. A queue uses the same two storage options but pulls from the opposite end, which is what forces the circular buffer trick when you back it with an array. With a queue in your toolkit, **Hash Map (Dictionary) Basics** introduces the most-used data structure in real-world code: a key-value store that answers lookups in expected `O(1)`.

Not Started

0%

Queue
FIFO
Deque
Circular Queue
Data Structures
Beginner
Free
BFS

Practice Problems

1 problem

Sliding Window Maximum

Not Started
Hard

Find the maximum value in each sliding window of size k as it moves across the array.

Arrays
Sliding Window
Deque
Monotonic Queue
Advanced

289

5

Question Banks

1 item
Question Bank
Premium

Deque and Sliding Window Max

Five prompts on the monotonic deque pattern: implementing sliding window maximum, the invariant that makes it O(n), and adjacent online-statistics applications.

Python
deque
sliding-window
algorithms
interview-prep

981

27

Hard