Min Stack with O(1) Space
Medium
Stacks
Stack
Design
Implement min stack using O(1) extra space for getMin.
Constraints
Methods ≤ 3×10^4
Examples
Example 1:
Input: push 5
push 3
push 7
getMin
pop
getMin
Output: 3
3
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console