@@ -0,0 +1,1188 @@
+package leetcode;%0A%0Aimport java.util.Stack;%0A%0A/**%0A * https://leetcode.com/problems/implement-queue-using-stacks/%0A */%0Apublic class Problem225 %7B%0A    static class MyQueue %7B%0A        private Stack%3CInteger%3E stack1 = new Stack%3C%3E();%0A        private Stack%3CInteger%3E stack2 = new Stack%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            while (!stack1.isEmpty()) %7B%0A                stack2.push(stack1.pop());%0A            %7D%0A            stack2.pop();%0A            while (!stack2.isEmpty()) %7B%0A                stack1.push(stack2.pop());%0A            %7D%0A        %7D%0A%0A        // Get the front element.%0A        public int peek() %7B%0A            while (!stack1.isEmpty()) %7B%0A                stack2.push(stack1.pop());%0A            %7D%0A            int front = stack2.peek();%0A            while (!stack2.isEmpty()) %7B%0A                stack1.push(stack2.pop());%0A            %7D%0A            return front;%0A        %7D%0A%0A        // Return whether the queue is empty.%0A        public boolean empty() %7B%0A            return stack1.isEmpty();%0A        %7D%0A    %7D%0A%7D%0A

Solve problem 225