- A stack is a linear data structure that follows the LIFO (Last-In-First-Out) principle.
- The last element inserted is the first one to be deleted.
- Push: Insert an element at the top of the stack.
- Pop: Delete an element at the top of the stack.
- Peek: Get the value of the top element without removing it.
- IsEmpty: Check if the stack is empty.
- IsFull: Check if the stack is full.
- Balancing of symbols
- Infix to Postfix/Prefix conversions
- Redo-undo features at many places like editors, photoshop.
- Forward and backward feature in web browsers
- Used in many algorithms like Tower of Hanoi, tree traversals, stock span problem, histogram problem.
- Using Array
- Using Linked List
- Push: O(1)
- Pop: O(1)
- Peek: O(1)
- IsEmpty: O(1)
- IsFull: O(1)
- O(n)
- Undo/Redo
- Backtracking
- DFS
- Valid Parentheses | Easy | Solution | Problem Description
- Min Stack | Easy | Solution | Problem Description
- Evaluate Reverse Polish Notation | Medium | Solution | Problem Description
- Generate Parentheses | Medium | Solution | Problem Description
- Daily Temperatures | Medium | Solution | Problem Description
- Car Fleet | Medium | Solution | Problem Description
- Largest Rectangle in Histogram | Hard | Solution | Problem Description
Category: Stack
Status: Done
Author: David Bujosa