A Queue is a First-In-First-Out (FIFO) data structure — just like waiting in line at a store! 🏪
💡 Think of it like this: Imagine a line at a coffee shop. The first person in line gets served first. New people join at the back. No cutting! That's a queue.
Queue operations (all O(1) with deque):
q.append(x) — Enqueue: add to back of lineq.popleft() — Dequeue: remove from front (served!)q[0] — Peek: see who's at the frontlist.pop(0) — it's O(n)! Always use dequeWhere queues are used:
q.popleft()
A
q.popleft()
B
q[0]
C