A Stack with O(1) Minimum

easy
Unit 2 · Stacks & Dynamic Programming0/3 to milestone

Implement MinStack with push(x), pop() (returns the value), top(), get_min() and __len__, all in O(1). pop, top and get_min on an empty stack raise IndexError.

#stacks#design2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
A Stack with O(1) Minimum · TechGradify