import java.util.Stack; public class Solution { Stack<Integer> stack1 = new Stack<Integer>(); Stack<Integer> stack2 = new Stack<Integer>(); public void push(int node) { while(!stack2.empty()){ Integer nodeOnWay=stack2.pop(); stack1.push(nodeOnWay); } stack1.push(node); while(!stack1.empty()){ Integer nodeOnWay=stack1.pop(); stack2.push(nodeOnWay); } } public int pop() { if(!stack2.empty()) return stack2.pop(); else return -1; } }