CodeMosa
Master LeetCode Patterns
All Patterns
Collections
Sign In
Back
Min/Max Stack/Queue
Question 1 of 12
8% Complete
Medium
How do you implement a stack that supports getMin() in O(1)?
A
Maintain a second stack that stores the minimum at each level
B
Sort the stack after each operation
C
Use a heap alongside the stack
D
Scan the entire stack for minimum
Need a hint?
Think about tracking minimums alongside values