Stack Interview Questions

LIFO structures for parsing, monotonic stacks, and nested structures.

73 problems

#Title
20Valid Parentheses
32Longest Valid Parentheses
71Simplify Path
84Largest Rectangle in Histogram
85Maximal Rectangle
101Symmetric Tree
150Evaluate Reverse Polish Notation
155Min Stack
224Basic Calculator
227Basic Calculator II
232Implement Queue using Stacks
255Verify Preorder Sequence in Binary Search Tree
272Closest Binary Search Tree Value II
331Verify Preorder Serialization of a Binary Tree
341Flatten Nested List Iterator
385Mini Parser
394Decode String
439Ternary Expression Parser
456132 Pattern
496Next Greater Element I
503Next Greater Element II
636Exclusive Time of Functions
682Baseball Game
726Number of Atoms
735Asteroid Collision
736Parse Lisp Expression
739Daily Temperatures
770Basic Calculator IV
772Basic Calculator III
853Car Fleet
856Score of Parentheses
872Leaf-Similar Trees
895Maximum Frequency Stack
901Online Stock Span
921Minimum Add to Make Parentheses Valid
946Validate Stack Sequences
1003Check If Word Is Valid After Substitutions
1019Next Greater Node In Linked List
1021Remove Outermost Parentheses
1047Remove All Adjacent Duplicates In String
1063Number of Valid Subarrays
1130Minimum Cost Tree From Leaf Values
1190Reverse Substrings Between Each Pair of Parentheses
1209Remove All Adjacent Duplicates in String II
1441Build an Array With Stack Operations
1541Minimum Insertions to Balance a Parentheses String
1597Build Binary Expression Tree From Infix Expression
1856Maximum Subarray Min-Product
1944Number of Visible People in a Queue
1950Maximum of Minimum Values in All Subarrays
2104Sum of Subarray Ranges
2197Replace Non-Coprime Numbers in Array
2281Sum of Total Strength of Wizards
2282Number of People That Can Be Seen in a Grid
2334Subarray With Elements Greater Than Varying Threshold
2355Maximum Number of Books You Can Take
2454Next Greater Element IV
2696Minimum String Length After Removing Substrings
2735Collecting Chocolates
2736Maximum Sum Queries
2764is Array a Preorder of Some ‌Binary Tree
2832Maximal Range That Each Element Is Maximum in It
2863Maximum Length of Semi-Decreasing Subarrays
2865Beautiful Towers I
2866Beautiful Towers II
2899Last Visited Integers
3113Find the Number of Subarrays Where Boundary Elements Are Maximum
3174Clear Digits
3676Count Bowl Subarrays
3703Remove K-Balanced Substrings
3749Evaluate Valid Expressions
3834Merge Adjacent Equal Elements
3878Count Good Subarrays