16 Balanced brackets Medium Stack Matching

Check if every opening bracket has a matching closing bracket in the correct order.

O(n) time · O(n) space
17 Queue using two stacks Medium Lazy Transfer

Build a first-in-first-out queue using only two last-in-first-out stacks.

O(1) amortized per operation
18 Min stack Medium Pair with Min

Build a stack that also tells you the current minimum element in O(1) time.

O(1) all operations · O(n) space
19 Evaluate postfix expression Easy Operand Stack

Calculate the result of a math expression written in postfix notation like '2 1 + 3 *'.

O(n) time · O(n) space
20 Next greater element Medium Monotonic Stack

For each number in an array, find the first larger number to its right.

O(n) time · O(n) space
21 Valid parentheses string Easy Index Stack

Check if a string of parentheses is properly opened and closed.

O(n) time · O(n) space
22 Reverse string with stack Easy Push/Pop All

Reverse a string by pushing all characters onto a stack and popping them off.

O(n) time · O(n) space
134 Evaluate Reverse Polish Notation Medium Stack Eval

Evaluate a math expression written in postfix notation using a stack.

O(n) time · O(n) space
135 Daily Temperatures Medium Monotonic Stack

For each day, find how many days you have to wait until a warmer day comes.

O(n) time · O(n) space