0
Leetcode Problem 155. Min Stack
155. Min Stack
AI Mock Interview
Leetcode Solutions
Approach: Stack of Value/Minimum Pairs
Solution Idea
Algorithm Steps
Code Implementation
Complexity Analysis
Initialize a stack to store pairs of (value, current minimum).
On push, insert a pair of the value and the current minimum into the stack.
On pop, remove the top element from the stack.
On top, return the first element of the pair at the top of the stack.
On getMin, return the second element of the pair at the top of the stack.
Approach: Two Stacks
Ask Question
Programming Language
Purpose:
General Question
Debug My Code
image/screenshot of info
(optional)
[+]
Full Screen
Loading...
Get Answer
Suggested Answer
Answer
Full Screen
Copy Answer Code
Loading...
Sign in with LinkedIn
Sign in with Github
OR
Sign in with Email link