当前位置:网站首页>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); */
边栏推荐
- Understanding the difference between wait() and sleep()
- Get the ask code corresponding to the key pressed by the keyboard
- 2019 Shaanxi Provincial race K-variant Dijstra
- User defined annotation verification API parameter phone number
- PageHelper does not take effect, and SQL does not automatically add limit
- 获取键盘按下的键位对应ask码
- Idea eye care settings
- 小波变换--dwt2 与wavedec2
- How to understand the maximum allowable number of errors per client connection of MySQL parameters in Seata?
- JVM dynamic bytecode technology details
猜你喜欢

MySQL transactions and mvcc

《图书馆管理系统——“借书还书”模块》项目研发阶段性总结

Geogle Colab笔记1--运行Geogle云端硬盘上的.py文件
SQL cultivation manual from scratch - practical part

Cf888g clever dictionary tree + violent divide and conquer (XOR minimum spanning tree)

Delayed loading source code analysis:

Spark SQL null value, Nan judgment and processing

Pytorch学习笔记--Pytorch常用函数总结1

GAMES101复习:变换

ML - 语音 - 深度神经网络模型
随机推荐
Ml speech depth neural network model
Pytorch学习笔记--常用函数总结2
Binary complement
Idea eye care settings
GAMES101复习:线性代数
分布式原理 - 什么是分布式系统
<栈模拟递归>
ML - 语音 - 深度神经网络模型
UIDocumentInteractionController UIDocumentPickerViewController
苹果内购和Apple Pay 的区别
Xcode添加mobileprovision证书文件报错:Xcode encountered an error
Pytorch学习笔记-Advanced_CNN(Using Inception_Module)实现Mnist数据集分类-(注释及结果)
2019 Zhejiang race c-wrong arrangement, greedy
UIDocumentInteractionController UIDocumentPickerViewController
《图书馆管理系统——“借书还书”模块》项目研发阶段性总结
数据系统分区设计 - 请求路由
ML - natural language processing - Introduction to natural language processing
2021江苏省赛A. Array-线段树,维护值域,欧拉降幂
ML - 自然语言处理 - 基础知识
CF888G-巧妙字典树+暴力分治(异或最小生成树)