Min Stack (Get Minimum in O(1))
00:00
AmazonGoogle
Design a stack supporting push, pop, top, and getMin all in O(1) time and space efficiency.
Examples
Input → Ex1: push(-2),push(0),push(-3),getMin()=-3,pop(),top()=0,getMin()=-2
Output →
Input → Ex2: push(1),getMin()=1,push(0),getMin()=0,pop(),getMin()=1
Output →