classMyStack{ Queue<Integer> queue; /** Initialize your data structure here. */ publicMyStack(){ queue = new LinkedList<Integer>(); } /** Push element x onto stack. */ publicvoidpush(int x){ int n = queue.size(); queue.offer(x); for(int i = 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(); } }