@@ -0,0 +1,950 @@
+class MyQueue %7B%0A    Deque%3CInteger%3E stack1 = new ArrayDeque%3C%3E();%0A    Deque%3CInteger%3E stack2 = new ArrayDeque%3C%3E();%0A%0A    // Push element x to the back of queue.%0A    public void push(int x) %7B%0A        stack1.push(x);%0A    %7D%0A%0A    // Removes the element from in front of queue.%0A    public void pop() %7B%0A        if (!stack2.isEmpty()) %7B%0A            stack2.pop();%0A        %7D else %7B%0A            while (!stack1.isEmpty()) %7B%0A                stack2.push(stack1.pop());%0A            %7D%0A            stack2.pop();%0A        %7D%0A    %7D%0A%0A    // Get the front element.%0A    public int peek() %7B%0A        if (!stack2.isEmpty()) %7B%0A            return stack2.peek();%0A        %7D%0A        while (!stack1.isEmpty()) %7B%0A            stack2.push(stack1.pop());%0A        %7D%0A        return stack2.peek();%0A    %7D%0A%0A    // Return whether the queue is empty.%0A    public boolean empty() %7B%0A        if (stack1.isEmpty() && stack2.isEmpty()) %7B%0A            return true;%0A        %7D%0A        return false;%0A    %7D%0A%7D%0A

232. Implement Queue using Stacks