A queue is like a line at the movie theater. It's "first in, first out" (FIFO), which means that the item that was put in the queue longest ago is the first item that comes out. "First come, first served."
Queues have two main methods:
- enqueue : adds an item
- dequeue : removes and returns the next item in line
They can also include some utility methods:
- peek : returns the item at the front of the queue, without removing it.
- is_empty : returns True if the queue is empty, False otherwise
Pass Your Interviews with My FREE 7-Day Crash Course
I'll teach you the right way of thinking for breaking down tricky algorithmic coding interview questions you've never seen before.
No prior computer science training necessary—I'll get you up to speed quickly, skipping all the overly academic stuff.
No spam. One-click unsubscribe if you hate it.