class MyQueue { Deque<Integer> instack; Deque<Integer> outStack; /** Initialize your data structure here. */ public MyQueue() { instack = new LinkedList<>(); outStack = new LinkedList<>(); } /** Push element x to the back of queue. */ public void push(int x) { instack.push(x); } /** Removes the element from in front of queue and returns that element. */ public int pop() { if (outStack.isEmpty()) { inToOut(); } return outStack.pop(); } /** Get the front element. */ public int peek() { if (outStack.isEmpty()) { inToOut(); } return outStack.peek(); } private void inToOut() { while (!instack.isEmpty()) { outStack.push(instack.pop()); } } /** Returns whether the queue is empty. */ public boolean empty() { return instack.isEmpty() && outStack.isEmpty(); }}/** * 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(); */