Back to DSA sheet
Min Stack
MediumStack & QueueDesign a stack supporting push, pop, top, and retrieving the minimum element, all in O(1).
Constraints
- At most 3 * 10^4 calls
- -2^31 <= val <= 2^31 - 1
Sheets
Blind 75Grind 75NeetCode 150NeetCode 250
min-stack.cpp
Loading editor
Custom input (stdin)
Output
Run your code to see its output.