classMyQueue{privatefinalStack<Integer> inStack =newStack<>();privatefinalStack<Integer> outStack =newStack<>();/** Initialize your data structure here. */publicMyQueue(){}/** Push element x to the back of queue. */publicvoidpush(int x){if(outStack.empty()){
outStack.push(x);}else{while(!outStack.empty()){
inStack.push(outStack.pop());}
inStack.push(x);while(!inStack.empty()){
outStack.push(inStack.pop());}}}/** Removes the element from in front of queue and returns that element. */publicintpop(){return outStack.pop();}/** Get the front element. */publicintpeek(){return outStack.peek();}/** Returns whether the queue is empty. */publicbooleanempty(){return outStack.empty();}}/**
* Your MyQueue object will be instantiated and called as such:
* MyQueue obj = new MyQueue();
* obj.push(x);
* int param_2 = obj.pop();
* int param_3 = obj.peek();
* boolean param_4 = obj.empty();
*/