Design a stack that supports push, pop, top, and retrieving the minimum element — all in O(1) time.
push(-2), push(0), push(-3), getMin(), pop(), top(), getMin()[-3, 0, -2]push(5), push(3), push(7), getMin(), pop(), getMin(), push(1), getMin()[3, 3, 1]stack (values) and minSt (running minimums)min(val, minSt.peek()) to minStThe min-stack mirrors the main stack level-for-level. Each entry minSt[i] stores the minimum of the entire main stack at that depth. When an element is popped, its corresponding min entry is also discarded — so minSt.peek() always reflects the current minimum without any scanning.