If arrays are about storing data, stacks are about controlling the order you process it. They're one of the simplest data structures — but they show up in surprisingly many interview problems. This post breaks down what stacks are, how they work under the hood, and why the LIFO constraint is so powerful.
What is a stack?
A stack is a collection where the last element added is the first one removed. This is called LIFO — Last In, First Out.