Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Min Stack
Bookmark
Input
LeetCode Example
Mixed Ops
Push & Top
Custom
operations
=
[push -2, push 0, push -3, getMin, pop, top, getMin]
operations
push -2
push 0
push -3
getMin
pop
top
getMin
0
1
2
3
4
5
6
val
min
stack
algo
master
.
io
Step:
MinStack: each entry stores [value, currentMin] so getMin is O(1)
0 / 16
Input
LeetCode Example
Mixed Ops
Push & Top
Custom
operations
=
[push -2, push 0, push -3, getMin, pop, top, getMin]
0 / 16
operations
push -2
push 0
push -3
getMin
pop
top
getMin
0
1
2
3
4
5
6
val
min
stack
algo
master
.
io
Step:
MinStack: each entry stores [value, currentMin] so getMin is O(1)