LeetCode 225:用队列实现栈 Implement Stack using Queues
题目: 使用队列实现栈的下列操作: push(x) -- 元素 x 入栈 pop() -- 移除栈顶元素 top() -- 获取栈顶元素 empty() -- 返回栈是否为空 Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. empty() -- Return whether the stack is empty. 示例: MyStack stack = new MyStack(); stack.push(1); stack.push(2); stack.top(); // 返回 2 stack.pop(); // 返回 2 stack.empty(); // 返回 false 注意: 你只能使用队列的基本操作-- 也就是 push to back, peek/pop from fro...