队列实现栈
class MyStack{ private Queue<Integer> queue = new LinkedList<>(); public void push(int x){ queue.add(x); int cnt = queue.size(); while(cnt-->1){ queue.add(queue.poll()); } } public int pop(){ return queue.remove(); } public int top(){ return queue.peek(); } public boolean empty(){ return queue.isEmpty(); } }