class MyQueue {
public:
/** Initialize your data structure here. */
stack<int>in,out;
void transferable()
{
while(!in.empty())
{
out.push(in.top());
in.pop();
}
}
MyQueue()
{
}
/** Push element x to the back of queue. */
void push(int x)
{
in.push(x);
}
/** Removes the element from in front of queue and returns that element. */
int pop()
{
if(out.empty())
{
transferable();
}
int x= out.top();
out.pop();
return x;
}
/** Get the front element. */
int peek()
{
if(out.empty())
{
transferable();
}
return out.top();
}
/** Returns whether the queue is empty. */
bool empty()
{
return in.empty()&&out.empty();
}
};