Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Min Stack

Medium Stack

Design a stack that supports push x, pop, top and getMin, all in O(1). For every top and getMin operation print the result on its own line.

Constraints

1 <= q <= 3 * 10^4 -2^31 <= x <= 2^31 - 1 pop, top and getMin are only called on a non-empty stack

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.