Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 616 Bytes

File metadata and controls

35 lines (27 loc) · 616 Bytes

Maximum Element

Problem from Hackerrank

You have an empty sequence, and you will be given N queries. Each query is one of these three types:

  1. Push the element x into the stack.
  2. Delete the element present at the top of the stack.
  3. Print the maximum element in the stack.

The first line of input contains an integer, N . The next N lines each contain an above mentioned query. (It is guaranteed that each query is valid.)

Example

Input:

    10
    1 97
    2
    1 20
    2
    1 26
    1 20
    2
    3
    1 91
    3

Output::

   26
   91