当前位置:网站首页>Leetcode: sword finger offer 59 - ii Maximum value of queue [deque + sortedlist]
Leetcode: sword finger offer 59 - ii Maximum value of queue [deque + sortedlist]
2022-06-11 18:47:00 【Review of the white speed Dragon King】

analysis
Whatever it is o1
Just pick it up sortedlist + deque Simulation is enough
ac code
from sortedcontainers import SortedList
class MaxQueue:
def __init__(self):
self.lst = SortedList()
self.q = deque([])
def max_value(self) -> int:
if not self.q: return -1
return self.lst[-1]
def push_back(self, value: int) -> None:
self.q.append(value)
self.lst.add(value)
def pop_front(self) -> int:
if not self.q: return -1
val = self.q.popleft()
self.lst.remove(val)
return val
# Your MaxQueue object will be instantiated and called as such:
# obj = MaxQueue()
# param_1 = obj.max_value()
# obj.push_back(value)
# param_3 = obj.pop_front()
summary
deque and sortedlist Investigate
边栏推荐
- cf:B. Array Decrements【模拟】
- *Use of jetpack notes room
- BottomSheetDialog 使用详解,设置圆角、固定高度、默认全屏等
- Visual slam lecture notes-10-2
- Flink CDC 在大健云仓的实践
- 2023年西安交通大学管理学院MPAcc提前批面试网报通知
- ubuntu 安装psql以及运行相关命令
- Téléchargement et téléchargement des fichiers nécessaires au développement
- 动态爆炸效果
- 全志科技T3開發板(4核ARM Cortex-A7)——MQTT通信協議案例
猜你喜欢

cf:C. Restoring the Duration of Tasks【找规律】

北京邮电大学2023级工商管理硕士MBA(非全日制)已开启

Quanzhi technology T3 development board (4-core arm cortex-a7) - mqtt communication protocol case

Niu Ke's question -- finding the least common multiple
![leetcode:剑指 Offer 59 - II. 队列的最大值[deque + sortedlist]](/img/6b/f2e04cd1f3aaa9fe057c292301894a.png)
leetcode:剑指 Offer 59 - II. 队列的最大值[deque + sortedlist]

使用图像处理技术和卷积神经网络(CNN)的作物病害检测

The US inflation rate reached a 41 year high of 8.6%! High inflation fever? The stock and encryption markets fell first!
2022 coming of age ceremony, to every college entrance examination student
Make a static tank

牛客刷题——不要二
随机推荐
Niu Ke's question -- Fibonacci series
2023年西安交通大学管理学院MPAcc提前批面试网报通知
JS实现全屏展示的具体方法
SA token single sign on SSO mode 2 URL redirection propagation session example
* Jetpack 笔记 使用DataBinding
Téléchargement et téléchargement des fichiers nécessaires au développement
Project management of workflow and business service on SAP BTP
Quanzhi technology T3 development board (4-core arm cortex-a7) - mqtt communication protocol case
User group actions
Financial bank_ Introduction to collection system
The nearest common ancestor of binary tree
全志T3开发板(4核ARM Cortex-A7)——系统启动阶段LOGO显示详解
* Jetpack 笔记 Room 的使用
视觉SLAM十四讲笔记-10-1
Niuke brush questions part6
Why is ti's GPMC parallel port more often used to connect FPGA and ADC? I give three reasons
Niu Ke swipes the question -- converting a string to an integer
Force buckle 34 finds the first and last positions of elements in a sorted array
求数据库设计毕业信息管理
非递归实现二叉树的前、中、后序遍历