#C307. Linked List Minimum Stack

    ID: 46456 Type: Default 1000ms 256MiB

Linked List Minimum Stack

Linked List Minimum Stack

You are required to implement a stack using a linked list that supports the following operations:

  • push x: Push an integer x onto the stack.
  • pop: Remove the top element from the stack and print its value. If the stack is empty, print EMPTY.
  • peek: Print the top element. If the stack is empty, print EMPTY.
  • get_min: Print the minimum element in the current stack. If the stack is empty, print EMPTY. The minimum element is defined as the smallest integer in the stack.
  • is_empty: Print True if the stack is empty, otherwise print False.

Note: Your implementation must maintain and track the minimum element in the stack in O(1) time per query. Use an auxiliary strategy (such as an extra stack) if needed. All operations that require an output should print their result immediately to standard output.

The input will be provided via standard input and output should be printed to standard output.

inputFormat

The first line contains an integer n, representing the number of operations. Each of the following n lines contains an operation in one of the following formats:

  • push x - where x is an integer.
  • pop
  • peek
  • get_min
  • is_empty

outputFormat

For each operation that produces an output (pop, peek, get_min, and is_empty), print the result on a new line. If an operation (pop, peek, or get_min) is performed on an empty stack, print EMPTY. For the is_empty operation, print True if the stack is empty, otherwise print False.

## sample
6
push 5
push 3
get_min
pop
peek
is_empty
3

3 5 False

</p>