Design a data structure that supports the standard stack operations (push, pop, top) and an additional operation to retrieve the minimum element in O(1) time. The data structure should be able to handle a large number of elements and operations efficiently.
Explanation: The minimum value after the first three push operations is 7. After popping one element, the minimum value becomes 17.
Explanation: The minimum value after the first three push operations is 13. After popping one element, the minimum value becomes 23.
Stack with O(1) minimum retrieval
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak