classMaxQueue{private:
queue<int> myQueue;
deque<int> myDeque;public:MaxQueue(){}intmax_value(){return myQueue.empty()?-1:myDeque.front();}voidpush_back(int value){while((!myDeque.empty())&&(value>myDeque.back())){
myDeque.pop_back();}
myQueue.push(value);
myDeque.push_back(value);}intpop_front(){if(myQueue.empty()){return-1;}int temp=myQueue.front();if(temp==myDeque.front()){
myDeque.pop_front();}
myQueue.pop();return temp;}};/**
* Your MaxQueue object will be instantiated and called as such:
* MaxQueue* obj = new MaxQueue();
* int param_1 = obj->max_value();
* obj->push_back(value);
* int param_3 = obj->pop_front();
*/