A stack is like a stack of plates. It's "last in, first out" (LIFO), which means the item that was put in the stack most recently is the first item that comes out.
Stacks have two main methods:
- push : adds an item
- pop : removes and returns the top item
They can also include some utility methods:
- peek : returns the item on the top of the stack, without removing it.
- is_empty : returns True if the stack 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.