← All topics

Lesson

Queue & Deque

FIFO and double-ended queues for BFS and sliding extrema.

Easy → MediumTime O(n)Space O(n)
Practice problems
Loading visualization…

Loading solution…

BFS partner

Queues process nodes in discovery order — essential for shortest paths in unweighted graphs and level-order trees.

Monotonic deque

Maintain candidates for window max/min so the front is always the answer for the current window.

Pitfalls

  • !Using list.shift in JS (O(n))
  • !Forgetting to expire out-of-window indices

Practice from this topic

Showing 24 of the related problems in the 1000-question bank.

View all →

Got the lesson?

Mark Queue & Deque as understood when the ideas stick.