Design a stack that supports the standard push and pop operations, along with a minKeep operation which returns the smallest element in the stack. Implement the stack such that all operations are performed in O(1) time complexity.
Explanation: After pushing 97, 48, and 35, the smallest element is 35. After popping one element, the smallest element becomes 48.
Explanation: Pushing 25 and 52, the smallest is 25. After pushing 12, the smallest element becomes 12.
Stack with O(1) minimum retrieval
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak