Sequence example
Input
push(2), push(0), push(3), push(0), get_min(), pop(), get_min()
Output
0 then 0
After pushes the minimum is 0; pop removes the last 0, but a previous 0 remains so min is still 0.
Full lesson preview
Build a stack that supports push, pop, top, and retrieving the minimum element in constant time.
Problem statement
Task
Examples
Input
push(2), push(0), push(3), push(0), get_min(), pop(), get_min()
Output
0 then 0
After pushes the minimum is 0; pop removes the last 0, but a previous 0 remains so min is still 0.
Input format
Output format
Constraints
Samples
Input
(lambda s: (s.push(1), s.push(0), s.get_min())[-1])(MinStack())
Output
0
Push 1 then 0; get_min returns 0.