Stack Data Structure
Last Updated :
23 Jul, 2025
Improve
A Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). LIFO implies that the element that is inserted last, comes out first and FILO implies that the element that is inserted first, comes out last.
It behaves like a stack of plates, where the last plate added is the first one to be removed. Think of it this way:
- Pushing an element onto the stack is like adding a new plate on top.
- Popping an element removes the top plate from the stack.
Basics
- Introduction to Stack
- Stack Array Implementation
- Stack Linked List Implementation
- Stack Implementation using Deque
- Applications of Stack
Implementations in Different Languages
Easy Problems
- The Celebrity Problem
- Queue using Stacks
- Two stacks in an array
- Stack using Queues
- Stack using priority queue
- Stack using single queue
- Infix to Postfix
- Prefix to Infix
- Prefix to Postfix
- Postfix to Prefix
- Postfix to Infix
- Infix To Prefix
- Check for balanced parentheses
- Arithmetic Expression Evalution
- Evaluation of Postfix Expression
- Reverse a stack using recursion
- Reverse Words
- Reverse a string using stack
- Reversing a Queue
- Reversing the first K of a Queue
- A DS with O(1) Operations
Medium Problems
- k Stacks in an Array
- Mergable Stack
- Previous Smaller Element
- Next Greater Element
- Stock Span Problem
- Buildings Facing Sun
- Next Smaller of next Greater
- Next Greater Frequency Element
- Max product of indexes of greater on left and right
- Iterative Tower of Hanoi
- Sort a Stack
- Reverse a Stack
- Delete middle of a stack
- Check for queue sortable
- Check for stack sortable
- Index of closing bracket for a given opening bracket
- Max Diff between nearest left and right smaller
- Delete consecutive same words
Hard Problems
- Largest Rectangular Area in a Histogram
- Sum of Max of all Subarrays
- Max of Mins of every window size
- Stack that supports getMin()
- Stack with max frequency
- Longest valid substring
- Check Redundant Bracket
- Stack Permutations
- Remove brackets containing + and – operators
Quick Links :
Recommended:
Stack Data Structure
Visit Course

Stack Data Structure
