Stack
LeetCode 488: Zuma Game
·3 mins
LeetCode
Hard
Dynamic-Programming
Memoization
Breadth-First-Search
String
Stack
LeetCode 488 note: with at most 16 balls on the board and 5 in hand, memoize DFS on the whole (board, hand) state, inserting only before a same-colored ball or between two equal balls
LeetCode 3834: Merge Adjacent Equal Elements
·2 mins
LeetCode
Medium
Stack
Simulation
Array
LeetCode 3834 note: a stack simulation where a new element merges with an equal top, possibly again with the new top
LeetCode 3816: Lexicographically Smallest String After Deleting Duplicate Characters
·3 mins
LeetCode
Hard
Stack
Monotonic-Stack
Greedy
String
LeetCode 3816 note: a monotonic stack that deletes a larger top while another copy exists, then trims duplicate letters off the end since a prefix is always smaller
LeetCode 394: Decode String
·2 mins
LeetCode
Medium
Stack
String
Recursion
LeetCode 394 note: on [ push the current string and count, on ] pop and combine; counts can have several digits
LeetCode 3703: Remove K-Balanced Substrings
·2 mins
LeetCode
Medium
Stack
String
Simulation
LeetCode 3703 note: repeated replace is O(n^2); a stack of (character, run length) removes k ( plus k ) as soon as they line up
LeetCode 901: Online Stock Span
·2 mins
LeetCode
Daily
Medium
Stack
Monotonic-Stack
Data-Structures
Design
Design-Patterns
Stock
Solving the Online Stock Span problem using monotonic stack approach
LeetCode 853: Car Fleet
·2 mins
LeetCode
Daily
Medium
Array
Stack
Greedy
Simulation
Sorting
Solving the Car Fleet problem using stack-based approach
LeetCode 84: Largest Rectangle in Histogram
·3 mins
LeetCode
Daily
Hard
Array
Stack
Monotonic-Stack
Dynamic-Programming
Geometry
Histogram
Solving the Largest Rectangle in Histogram problem using monotonic stack approach
LeetCode 739: Daily Temperatures
·2 mins
LeetCode
Daily
Medium
Array
Stack
Monotonic-Stack
Data-Structures
Temperature
Waiting-Time
Solving the Daily Temperatures problem using monotonic stack approach
LeetCode 20: Valid Parentheses
·2 mins
LeetCode
Daily
Easy
String
Stack
Data-Structures
Parentheses
Validation
Solving the Valid Parentheses problem using stack-based approach
LeetCode 155: Min Stack
·2 mins
LeetCode
Daily
Medium
Stack
Constant-Time
Data-Structures
Design
Tuple
Implementing a stack with O(1) minimum retrieval using tuple-based approach
LeetCode 150: Evaluate Reverse Polish Notation
·2 mins
LeetCode
Daily
Medium
Stack
Data-Structures
Expression-Evaluation
Math
Postfix-Notation
Reverse-Polish-Notation
Solving the Reverse Polish Notation evaluation problem using stack-based approach