Min Stack with O(1) Space

Medium
Stacks Stack Design

Implement min stack using O(1) extra space for getMin.

Constraints

Methods ≤ 3×10^4

Examples

Example 1:
Input: push 5 push 3 push 7 getMin pop getMin
Output: 3 3
▲ Console

Install Talent Arabia

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