Stack<Integer> stack1 = new Stack<Integer>();
Stack<Integer> stack2 = new Stack<Integer>();
public void push(int node) {
stack1.push(node);
}
public int pop() {
int a;
while(!stack1.isEmpty()){
a=stack1.pop();
stack2.push(a);
}
int b=stack2.pop();
while(!stack2.isEmpty()){
a=stack2.pop();
stack1.push(a);
}
return b;
}
Stack<Integer> stack2 = new Stack<Integer>();
public void push(int node) {
stack1.push(node);
}
public int pop() {
int a;
while(!stack1.isEmpty()){
a=stack1.pop();
stack2.push(a);
}
int b=stack2.pop();
while(!stack2.isEmpty()){
a=stack2.pop();
stack1.push(a);
}
return b;
}