@@ -0,0 +1,1533 @@
+/**%0A * Implement the following operations of a queue using stacks. %0A * %09%09push(x) -- Push element x to the back of queue.p%0A * %09%09pop() -- Removes the element from in front of queue.p%0A * %09%09peek() -- Get the front element.%0A * %09%09empty() -- Return whether the queue is empty.%0A * Notes:%0A * You must use only standard operations of a stack -- which means only push to top, peek/pop from top, size, and is empty operations are valid.%0A * Depending on your language, stack may not be supported natively. You may simulate a stack by using a list or deque (double-ended queue), as long as%0A * you use only standard operations of a stack.%0A * You may assume that all operations are valid (for example, no pop or peek operations will be called on an empty queue).%0A * @author Jun%0A *%0A */%0A %0Aclass MyQueue %7B%0A    Stack%3CInteger%3E tmp = new Stack%3CInteger%3E();%0A    Stack%3CInteger%3E result = new Stack%3CInteger%3E();%0A    %0A    // Push element x to the back of queue.%0A    public void push(int x) %7B%0A        if(result.empty()) %7B%0A            result.push(x);%0A            return;%0A        %7D%0A        while(!result.empty())%0A            tmp.push(result.pop());%0A        result.push(x);%0A        while(!tmp.empty())%0A            result.push(tmp.pop());%0A        return;%0A    %7D%0A%0A    // Removes the element from in front of queue.%0A    public void pop() %7B%0A        result.pop();%0A    %7D%0A%0A    // Get the front element.%0A    public int peek() %7B%0A        return result.peek();%0A    %7D%0A%0A    // Return whether the queue is empty.%0A    public boolean empty() %7B%0A        return result.empty();%0A    %7D%0A%7D%0A

Create 232.java