链接:https://leetcode.cn/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/description/?favorite=xb9nqhhg
题目:
思路:
class CQueue {
public:
stack<int>a,b;
CQueue() {
}
void appendTail(int value) {
a.push(value);
}
int deleteHead() {
if(a.size()==0)
{
return -1;
}
while(a.size()!=0)
{
int c=a.top();
b.push(c);
a.pop();
}
int tmp=b.top();
b.pop();
while(b.size()!=0)
{
int c=b.top();
a.push(c);
b.pop();
}
return tmp;
}
};
/**
* Your CQueue object will be instantiated and called as such:
* CQueue* obj = new CQueue();
* obj->appendTail(value);
* int param_2 = obj->deleteHead();
*/