-->
当前位置:首页 > 题库

PROGRAMMING:Design and implement a minstack class based on minimal stack

Luz5年前 (2021-05-10)题库611
Minimum stack design and implementation of a minstack class, requires at least the following three methods
1、 * * push * * method: stack an integer
2、 * * pop * * method: pop up the top of stack element
3、 * * getmin * * method: output the smallest element in the stack
###Input format:
In the first line, enter an n to indicate the number of operations to be performed next
Then n lines indicate the operation:
The push method is followed by the element to stack
Pop method and getmin method are not followed by any elements
**Description * *: assuming that there is no other invalid input and the stack is not empty when executing getmin and pop methods
###Output example:
Output the smallest element in the stack
###Input example:
```in
five
push 2
push 3
push 1
pop
getmin
```
###Output example:
```out
two
```







answer:If there is no answer, please comment