Company: IMC Trading Amsterdam
Difficulty: medium
Stack Batch Removal Problem Description Implement a stack of integers that accepts the following commands. push <value> : push value onto the top of the stack. pop : remove the top element of the stack. remove_lower <value> : remove every element currently in the stack that is strictly less than value , wherever it sits in the stack. remove_upper <value> : remove every element currently in the stack that is strictly greater than value , wherever it sits in the stack. After each command, print the value now on top of the stack. If the stack is empty at that moment, print EMPTY . Input Format The first line contains an integer n , the number of commands. Each of the next n lines contains one command, written exactly as push <value> , pop , remove_lower <value> or remove_upper <value> . Output Format Print n lines. Line i holds the top element of the stack after command i has been carried out, or EMPTY if the stack holds nothing at that point. Constrain