Basic Stack Problems for Coding Interviews
16 basic Stack problems from real coding interviews, each with test cases you can run online. By difficulty they split into 16 basic, 0 intermediate and 0 advanced. The companies that ask them most often are Amazon, Bloomberg, Google, Meta.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Valid Parentheses (Basic)
- Remove Outer Parentheses (Basic)
- Generate Balanced Bracket Types (Basic)
- Boolean Parenthesization Count (Basic)
- Binary Tree Inorder Traversal (Basic)
- Binary Tree Preorder Traversal (Basic)
- Min Stack Operations (Basic)
- Minimum Add to Make Parentheses Valid (Basic)
- Construct String From Binary Tree (Basic)
- Maximum Nesting Depth of Parentheses (Basic)
- Monotonic Array (Basic)
- Implement Queue Using Stacks (Basic)
- Build an Array With Stack Operations (Basic)
- Count Balanced Bracket Prefixes (Basic)
- Stacked Discount Final Price (Basic)
- Shipping Cost by Weight Brackets (Basic)
Related
Frequently asked questions
How do I get good at stack problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run stack problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.