1 <= push_back,pop_front,max_value的总操作数 <= 10000
1 <= value <= 10^5
一、解题关键词
二、解题报告
1.思路分析
2.时间复杂度
3.代码示例
classMaxQueue{int[] queue =newint[20000];int begin =0,end =0;publicMaxQueue(){}publicintmax_value(){int ans =-1;for(int i = begin;i != end;i++){
ans =Math.max(ans,queue[i]);}return ans;}publicvoidpush_back(int value){
queue[end++]= value;}publicintpop_front(){if(begin == end){return-1;}return queue[begin++];}}/**
* 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();
*/