当前位置:网站首页>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); */
边栏推荐
- Xcode added mobileprovision certificate file error: Xcode encoded an error
- 4PAM在高斯信道与瑞利信道下的基带仿真系统实验
- MySQL transactions and mvcc
- C # carefully sorting out key points of knowledge 11 entrustment and events (recommended Collection)
- Hdu3873 shortest path with dependency (topological sorting)
- 二进制补码
- 带你详细认识JS基础语法(建议收藏)
- Is it safe to open futures online? Which company has the lowest handling charge?
- Pytorch学习笔记-刘二老师RNN高级篇-代码注释及结果
- 为什么PrepareStatement性能更好更安全?
猜你喜欢

ML - 语音 - 高级语音模型

图论及概念

JVM knowledge brain map sharing

Ml speech depth neural network model

Pytorch学习笔记-刘二老师RNN高级篇-代码注释及结果

Brain racking CPU context switching

理解“平均负载”

Phased summary of the research and development of the "library management system -" borrowing and returning "module

ML - 自然语言处理 - 自然语言处理简介

ML - 图像 - 深度学习和卷积神经网络
随机推荐
MySQL optimization summary II
Pytorch学习笔记--常用函数总结3
p4552-差分
In depth: micro and macro tasks
MySQL heap table_ MySQL memory table heap Usage Summary - Ninth Five Year Plan small pang
ML - 自然语言处理 - 基础知识
ML - natural language processing - Introduction to natural language processing
User defined annotation verification API parameter phone number
CF365-E - Mishka and Divisors,数论+dp
Pytorch学习笔记--SEResNet50搭建
Remember that spark foreachpartition once led to oom
2021上海市赛-H-二分答案
matlab 优化工具 manopt 安装
2021hncpc-e-difference, thinking
2019 Shaanxi Provincial race K-variant Dijstra
MATLAB读取显示图像时数据格式转换原因
PageHelper does not take effect, and SQL does not automatically add limit
数据系统分区设计 - 分区与二级索引
Spark judges that DF is empty
Node learning