Stacks

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.

Loading...

Stacks have two main methods:

  1. push : adds an item
  2. pop : removes and returns the top item

They can also include some utility methods:

  1. peek : returns the item on the top of the stack, without removing it.
  2. is_empty : returns True if the stack is empty, False otherwise

See also:

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.

Psst. Pass it on.

. . .