class MyQueue {
public:
/* Initialize your data structure here. /
stack[HTML_REMOVED] s1,s2;
MyQueue() {
}
/** Push element x to the back of queue. */
void push(int x) {
s1.push(x);
}
/** Removes the element from in front of queue and returns that element. */
int pop() {
if (!s2.empty()){
int k = s2.top();
s2.pop();
return k;
}
else{
if (!s1.empty()){
while(!s1.empty()){
int k = s1.top();
s1.pop();
s2.push(k);
}
int k = s2.top();
s2.pop();
return k;
}
}
}
/** Get the front element. */
int peek() {
if (!s2.empty()){
return s2.top();
}
else{
while(!s1.empty()){
int k = s1.top();
s1.pop();
s2.push(k);
}
return s2.top();
}
}
/** Returns whether the queue is empty. */
bool empty() {
return s1.empty() && s2.empty();
}
};
/*
* Your MyQueue object will be instantiated and called as such:
* MyQueue obj = MyQueue();
* obj.push(x);
* int param_2 = obj.pop();
* int param_3 = obj.peek();
* bool param_4 = obj.empty();
/