Queue
First in, first out — fair ordering, BFS, and the deque that does both ends.
This topic is part of Pro.
Free covers the C and Python courses, the first three DSA topics, the opening system design lessons and the beginner AI lessons, all with the full coach. Pro opens the rest of the library in the FollowtheDamnCode app.
What is in it
- 1How queues workEnqueue at the back, dequeue at the front — and why a ring buffer or deque keeps both O(1). Pro
- 2A queue from two stacksPour one stack into another only when it's empty, and every operation is O(1) amortized. Pro
- 3Breadth-first search with a queueSpread outward one ring at a time; the first time you reach something is the shortest way there. Pro