Daily iOS
CS fundamentals and algorithms

Stacks and queues

What's the difference between a stack and a queue?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

A stack is LIFO (the last thing in comes out first), a queue is FIFO (the first thing in comes out first). Both have fixed ends for adding and removing, so insertion and removal are O(1).

Share a question