|
| 1 | +# Maximum Element |
| 2 | +### Problem from Hackerrank Practice > DataStructures > Stacks |
| 3 | + |
| 4 | +You have an empty sequence, and you will be given **N** queries. Each query is one of these three types: |
| 5 | + |
| 6 | +- 1 x -Push the element x into the stack. |
| 7 | +- 2 -Delete the element present at the top of the stack. |
| 8 | +- 3 -Print the maximum element in the stack. |
| 9 | + |
| 10 | +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.) |
| 11 | + |
| 12 | +## Example: |
| 13 | +### Input:<br> |
| 14 | +10<br> |
| 15 | +1 97<br> |
| 16 | +2<br> |
| 17 | +1 20<br> |
| 18 | +2<br> |
| 19 | +1 26<br> |
| 20 | +1 20<br> |
| 21 | +2<br> |
| 22 | +3<br> |
| 23 | +1 91<br> |
| 24 | +3<br> |
| 25 | + |
| 26 | +### Output:<br> |
| 27 | +26<br> |
| 28 | +91<br> |
0 commit comments