#include <stack>
using namespace std;
class MyQueue {
private:
stack<int> stack_in_;
stack<int> stack_out_;
void pour_to_stack_out_() {
while (!stack_in_.empty()) {
int top = stack_in_.top();
stack_in_.pop();
stack_out_.push(top);
}
};
public:
/** Initialize your data structure here. */
MyQueue() {
}
/** Push element x to the back of queue. */
void push(int x) {
stack_in_.push(x);
}
/** Removes the element from in front of queue and returns that element. */
int pop() {
if (stack_out_.empty()) {
pour_to_stack_out_();
}
int top = stack_out_.top();
stack_out_.pop();
return top;
}
/** Get the front element. */
int peek() {
if (stack_out_.empty()) {
pour_to_stack_out_();
}
return stack_out_.top();
}
/** Returns whether the queue is empty. */
bool empty() {
return stack_in_.empty() && stack_out_.empty();
}
};
/**
* Your MyQueue object will be instantiated and called as such:
* MyQueue* obj = new MyQueue();
* obj->push(x);
* int param_2 = obj->pop();
* int param_3 = obj->peek();
* bool param_4 = obj->empty();
*/