Design a stack that supports push, pop, top, and retrieving the maximum element in O(1) time.
Constraints
Example
>>> s = MaxStack() >>> s.push(5) >>> s.push(1) >>> s.push(5) >>> s.get_max() 5 >>> s.pop() 5 >>> s.get_max() 5 >>> s.top() 1 >>> s.pop() 1 >>> s.get_max() 5 >>> s.pop() 5
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints