思路:
// @Title: 图书整理 II (图书整理 II)
// @Author: qisiii
// @Date: 2022-02-19 20:13:16
// @Runtime: 61 ms
// @Memory: 47.5 MB
// @comment:
// @flag:
class CQueue {
private Stack<Integer> pushStack=new Stack();
private Stack<Integer> popStack=new Stack();
public CQueue() {
}
public void appendTail(int value) {
pushStack.push(Integer.valueOf(value));
}
public int deleteHead() {
if (popStack.isEmpty()){
while (!pushStack.isEmpty()){
Integer pop = pushStack.pop();
popStack.push(pop);
}
}
if (popStack.isEmpty()){
return -1;
}
return popStack.pop();
}
}
/**
* Your CQueue object will be instantiated and called as such:
* CQueue obj = new CQueue();
* obj.appendTail(value);
* int param_2 = obj.deleteHead();
*/