Design a stack that supports constant time complexity for retrieving the minimum element, along with standard push and pop operations.
Explanation: Push 17 and 23 onto the stack. The minimum value is 17. After popping one element (17), the minimum value becomes 23.
Explanation: Push 42, 91, and 13 onto the stack. The minimum value is 13. After popping one element (13), the minimum value becomes 42.
Stack with O(1) minimum retrieval
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak