Dsa
Monotonic Stack
Hard
Minimum Stack
Design a stack that supports the following operations: push, pop, top, and retrieving the minimum element in constant time. Your implementation should be a class `MinStack` with methods: `push(val: int), pop(), top() -> int, get_min() -> int`.
### Input
A sequence of operations mixed with integers, such as 'push 1', 'pop', 'get_min', etc.
### Output
After all operations, print the minimum element in the stack. If the stack is empty when 'get_min' is called, return 'None'.
### Example
Input:
push 5
push 3
push 8
get_min
pop
get_min
Output:
3
5
Key concepts
monotonic_stackstackminimum
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now