当前位置:网站首页>LeetCode - 379 电话目录管理系统(设计)
LeetCode - 379 电话目录管理系统(设计)
2022-07-25 15:32:00 【三岁就很萌@D】



双端队列
class PhoneDirectory {
private Deque<Integer> deque;
public PhoneDirectory(int maxNumbers) {
deque = new LinkedList<>();
for(int i = 0; i < maxNumbers;i++)
deque.offerLast(i);
}
public int get(){
if(deque.size()!=0)
return deque.pollFirst();
else
return -1;
}
public boolean check(int number) {
return deque.contains(number);
}
public void release(int number) {
if(!deque.contains(number))
deque.offerLast(number);
}
}
/** * Your PhoneDirectory object will be instantiated and called as such: * PhoneDirectory obj = new PhoneDirectory(maxNumbers); * int param_1 = obj.get(); * boolean param_2 = obj.check(number); * obj.release(number); */
边栏推荐
- MySQL heap table_ MySQL memory table heap Usage Summary - Ninth Five Year Plan small pang
- Geogle Colab笔记1--运行Geogle云端硬盘上的.py文件
- Idea eye care settings
- Xcode添加mobileprovision证书文件报错:Xcode encountered an error
- Cf566a greed + dictionary tree
- See a lot of blinking pictures on apps, especially the member page
- ML - 图像 - 深度学习和卷积神经网络
- MATLAB 如何生产随机复序列
- PAT甲级1151 LCA in a Binary Tree (30 分)
- C # carefully sorting out key points of knowledge 11 entrustment and events (recommended Collection)
猜你喜欢

matlab--CVX优化工具包安装

No tracked branch configured for branch xxx or the branch doesn‘t exist. To make your branch trac

Games101 review: 3D transformation

带你创建你的第一个C#程序(建议收藏)

Take you to create your first C program (recommended Collection)

4PAM在高斯信道与瑞利信道下的基带仿真系统实验

ML - natural language processing - Introduction to natural language processing

MATLAB读取显示图像时数据格式转换原因

wait()和sleep()的区别理解

Box avoiding mouse
随机推荐
<栈模拟递归>
单例模式3--单例模式
How to solve the login problem after the 30 day experience period of visual stuido2019
Spark memory management mechanism new version
2016CCPC网络选拔赛C-换根dp好题
UITextField的inputView和inputAccessoryView注意点
我想问下变量配置功能是只能在SQL模式下使用吗
ICPC2021昆明M-暴力+主席树
Delayed loading source code analysis:
Understanding the difference between wait() and sleep()
ML - 自然语言处理 - 基础知识
小波变换--dwt2 与wavedec2
matlab 如何保存所有运行后的数据
Submarine cable detector tss350 (I)
Is it safe to open futures online? Which company has the lowest handling charge?
window系统黑窗口redis报错20Creating Server TCP listening socket *:6379: listen: Unknown error19-07-28
哪里有搭建flink cdc抽mysql数的demo?
JS URLEncode function
Spark partition operators partitionby, coalesce, repartition
Distributed principle - what is a distributed system