class Solution {
public:
void push(int element){
q1.push(element);
while(!q2.empty()){
int tmp=q2.front();
q2.pop();
q1.push(tmp);
}
while(!q1.empty()){
int tmp=q1.front();
q1.pop();
q2.push(tmp);
}
}
int pop(){
int tmp=q2.front();
q2.pop();
return tmp;
}
int top(){
return q2.front();
}
bool empty(){
if(!q2.empty())
return false;
else
return true;
}
private:
queue<int> q1;
queue<int> q2;
};

京公网安备 11010502036488号