class MyQueue {
Deque<Integer> inStack;
Deque<Integer> outStack;
public MyQueue(){
inStack = new LinkedList<Integer>();
outStack = new LinkedList<Integer>();}
public voidpush(int x){
inStack.push(x);}
public intpop(){if(outStack.isEmpty()){in2out();}return outStack.pop();}
public intpeek(){if(outStack.isEmpty()){in2out();}return outStack.peek();}
public boolean empty(){return inStack.isEmpty()&& outStack.isEmpty();}
private voidin2out(){while(!inStack.isEmpty()){
outStack.push(inStack.pop());}}}
题目代码class MyQueue { Deque<Integer> inStack; Deque<Integer> outStack; public MyQueue() { inStack = new LinkedList<Integer>(); outStack = new LinkedList<Integer>(); } public void push(int x