Min Stack

Easy
Stacks Stack Design

Design a stack that supports push, pop, top, and getMin in O(1) time.

Constraints

Methods ≤ 3×10^4

Examples

Example 1:
Input: push -2 push 0 push -3 getMin pop top getMin
Output: -3 0 -2
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.