LeetCode p232 Implement Queue using Stacks 题解
1.题目:
Implement the following operations of a queue using stacks.
push(x) -- Push element x to the back of queue.
pop() -- Removes the element from in front of queue.
peek() -- Get the front element.
empty() -- Return whether the queue is empty.
题意:
用栈实现队列
2.解题思路:
见代码,两个栈。
3.代码
1 |
|