CQueue() { } voidappendTail(int value){ stk.push(value); } intdeleteHead(){ if (stk.empty()) return-1; while (stk.size()) cache.push(stk.top()), stk.pop(); int val = cache.top(); cache.pop(); while (cache.size()) stk.push(cache.top()), cache.pop(); return val; } };
/** * Your CQueue object will be instantiated and called as such: * CQueue* obj = new CQueue(); * obj->appendTail(value); * int param_2 = obj->deleteHead(); */