import java.util.Stack;
public class Solution {
Stack<Integer> stack1 = new Stack<Integer>();
Stack<Integer> stack2 = new Stack<Integer>();
public void push(int node) {
stack1.push(node);
}
public int pop() {
//这里要判一下stack2是否为空,
//否则比如如果先入栈1,2再出去1个(把1出去了),再入栈一个3的话,没出去的那个2就在stack2的栈底出不去了。
if(stack2.empty()){
while(!stack1.isEmpty()){
stack2.push(stack1.pop());
}
}
return stack2.pop();
}
}


京公网安备 11010502036488号