IntermediateRating 1300
Stack With Minimum
Process commands
push x, pop, top and min. Print the answers to top and min (each O(1)). The stack is never empty when asked.Input
n, then n commands.
Output
Answers.
Sample 1
Input
6 push -2 push 0 push -3 min pop min
Output
-3 -2
Sample 2
Input
2 push 5 top
Output
5
Output appears here