[LeetCode C++实现]232. Implement Queue using Stacks
232 Implement Queue using Stacks
实现原理是使用两个stack,每当peek或者pop时将stack in中的元素全部转移到out。借此实现先入先出。
最初始的代码实现为:
class MyQueue {
public:
/** Initialize your data structure here. */
MyQueue() {
}
/** Push element x to the back of queue. */
void push(int x) {
in.push(x);
}
/** Removes the element from i......