A stack is a LIFO (Last In First Out) data structure. Similar to a stack of plates.
It’s easy to implement using a Linked List. There’s only one access point; the top of the stack (head) and all following nodes point down or towards the tail. New nodes are added as the new head.
Operations
- push
- pop
- peek
- Reverse
- Popping every element from a stack and pushing it onto another stack
Key Algorithms
- Balanced Parentheses
- Next Greater Element
- LRU cache implementation
Common Problems
- Implement a stack using queues
- Implement a queue using a stack