/** Initialize your data structure here. */ publicMyQueue() { }
/** Push element x to the back of queue. */ publicvoidpush(int x) { while (!s1.isEmpty()) s2.push(s1.pop()); s2.push(x); while (!s2.isEmpty()) s1.push(s2.pop()); }
/** Removes the element from in front of queue and returns that element. */ publicintpop() { return s1.pop(); }
/** Get the front element. */ publicintpeek() { return s1.peek(); }
/** Returns whether the queue is empty. */ publicbooleanempty() { return s1.isEmpty(); }