class MyQueue {
private int front;
private Stack<Integer> in = null;
private Stack<Integer> out = null;
public MyQueue() {
in = new Stack<>();
out = new Stack<>();
}
public void push(int x) {
in.push(x);
}
/**
* Removes the element from in front of queue and returns that element.
*/
public int pop() {
if (out.empty()) {
int size = in.size();
for (int i = 0; i < size; i++)
out.push(in.pop());
}
return out.pop();
}
/**
* Get the front element.
*/
public int peek() {
if (out.empty()) {
int size = in.size();
for (int i = 0; i < size; i++)
out.push(in.pop());
}
return out.peek();
}
/**
* Returns whether the queue is empty.
*/
public boolean empty() {
return in.empty() && out.empty();
}
}