import java.util.Stack;
public class Solution_2zhan1duilie{
Stack<Integer> stack1 = new Stack<Integer>();
Stack<Integer> stack2 = new Stack<Integer>();
public void push(int node) {
stack1.push(node);
}
public int pop() {
int re=0;
while(!stack1.isEmpty()){
stack2.push(stack1.pop());
}
re=stack2.pop().intValue();
while(!stack2.isEmpty()){
stack1.push(stack2.pop());
}
return re;
}
}
java两个栈实现队列
最新推荐文章于 2019-03-29 14:54:39 发布