} int pop_front() { if(que.empty())return -1; int res = que.front(); if(res == dq.front()) dq.pop_front(); que.pop(); return res;
} };
/** * 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(); */
结果
1 2 3 4 5 6 7 8 9 10 11 12
执行用时: 100 ms , 在所有 C++ 提交中击败了 88.67% 的用户 内存消耗: 47.6 MB , 在所有 C++ 提交中击败了 35.40% 的用户 通过测试用例: 34 / 34