classMyStack { Queue<Integer> queue; /** Initialize your data structure here. */ publicMyStack() { queue = newLinkedList<Integer>(); } /** Push element x onto stack. */ publicvoidpush(int x) { intn= queue.size(); queue.offer(x); for(inti=0; i < n; i++){ queue.offer(queue.poll()); } } /** Removes the element on top of the stack and returns that element. */ publicintpop() { return queue.poll(); } /** Get the top element. */ publicinttop() { return queue.peek(); } /** Returns whether the stack is empty. */ publicbooleanempty() { return queue.isEmpty(); } }