package 二刷;
import java.util.Stack;
public class 剑指Offer_09_用两个栈实现队列 {
}
class CQueue {
private Stack<Integer> inStack;
private Stack<Integer> outStack;
public CQueue() {
inStack = new Stack<>();
outStack = new Stack<>();
}
public void appendTail(int value) {
inStack.push(value);
}
public int deleteHead() {
if (!outStack.isEmpty()) return outStack.pop();
if (inStack.isEmpty()) return -1;
if (outStack.isEmpty()){
while (!inStack.isEmpty()){
outStack.push(inStack.pop());
}
}
return outStack.pop();
}
}