The Codetikki masons stack glyphs one on top of another. They need a special stack that, in addition to push and pop, can return the maximum value currently in the stack ÔÇö all in constant time. Implement a max stack with operations: push x (push value x), pop (remove and print top), max (print current maximum). Input: first line n (number of operations), then n lines each containing an operation. Output: results of pop and max operations, one per line.
Example 1:
Example 2:
Constraints:
1 <= n <= 10^5 -10^9 <= x <= 10^9 No pop or max on empty stack
Tags:
