Skip to content

Stack

Stack

A stack is similar to a Queue, except it’s LIFO (last in, first out). Stacks work exactly like a deck of cards: add a card to the top of the deck and then remove the same card from the top of the deck.

Stacks have two operations: