import java.util.*;
import java.util.Stack;
public class Solution {
Stack<Integer> stack1=new Stack<>();
Stack<Integer> stack2=new Stack<>();
public void push(int node) {
stack1.add(node);
}
public void pop() {
stack1.pop();
}
public int top() {
return stack1.peek();
}
public int min() {
//取出栈顶给min初始化
int min=stack1.peek();
//将stack1里的数倒入stack2,并比较、更新min
while(!stack1.isEmpty()){
int p=stack1.pop();
if(p<min){
min=p;
}
stack2.add(p);
}
//再把stack2里的数倒回给stack1
while(!stack2.isEmpty()){
stack1.add(stack2.pop());
}
return min;
}
}