JZ05-用两个栈来实现一个队列
用两个栈实现队列
https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1&tab=answerKey
public int pop() { if (stack1.isEmpty() && stack2.isEmpty()) { return -1; } if (!stack2.isEmpty()) { return stack2.pop(); } while (!stack1.isEmpty()) {//把stack1的放入stack2 stack2.push(stack1.pop()); } return stack2.pop(); }