All Patterns
Pattern 20
Stack
LIFO (Last In First Out) data structure. Perfect for parsing strings, evaluating expressions, or matching pairs like parentheses.
Time
O(n)
Space
O(n)
Recognize it when
- Matching pairs like nested parentheses
- Evaluating postfix/RPN expressions
- Tracking state that needs to be reversed or rewound
Progress0/3
0 solved0 attempted
Questions — ordered by difficulty
#20Easy
Valid Parentheses
Given a string containing just (, ), {, }, [ and ], determine if the input string is valid.
stringstack
#155Medium
Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
stackdesign
#150Medium
Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation (postfix).
arraymathstack