Stack Applications
Essential applications of stack data structure for solving various algorithmic problems.
Expression evaluation
- Infix to Postfix: Convert infix notation to postfix
- Postfix Evaluation: Evaluate postfix expressions
- Infix Evaluation: Evaluate infix expressions directly
- Prefix Evaluation: Evaluate prefix expressions
Parentheses matching
- Balanced Parentheses: Check if parentheses are balanced
- Multiple Types: Handle different types of brackets
- Nested Brackets: Handle deeply nested bracket structures
- Minimum Additions: Find minimum parentheses to add
Monotonic stack
- Monotonic Increasing: Stack with increasing elements
- Monotonic Decreasing: Stack with decreasing elements
- Next Greater Element: Find next greater element for each
- Previous Greater Element: Find previous greater element
Next greater/smaller element
- Next Greater Element: Find next greater element to the right
- Next Smaller Element: Find next smaller element to the right
- Previous Greater Element: Find previous greater element to the left
- Previous Smaller Element: Find previous smaller element to the left
Histogram problems
- Largest Rectangle: Find largest rectangle in histogram
- Trapping Rain Water: Calculate trapped rainwater
- Maximum Area: Find maximum area under histogram
- Stack-based Solution: Using stack for efficient solution