当前位置:网站首页>2022.8.2-----leetcode.622
2022.8.2-----leetcode.622
2022-08-03 09:42:00 【路Lu727】
int k, he, ta;
int[] nums;
public MyCircularQueue(int _k) {
k = _k;
nums = new int[k];
}
public boolean enQueue(int value) {
if (isFull()) return false;
nums[ta % k] = value;
return ++ta >= 0;
}
public boolean deQueue() {
if (isEmpty()) return false;
return ++he >= 0;
}
public int Front() {
return isEmpty() ? -1 : nums[he % k];
}
public int Rear() {
return isEmpty() ? -1 : nums[(ta - 1) % k];
}
public boolean isEmpty() {
return he == ta;
}
public boolean isFull() {
return ta - he == k;
}
边栏推荐
- When deleting a folder, the error "Error ox80070091: The directory is not empty" is reported. How to solve it?
- STP生成树选举结果查看及验证
- Go Redis database operation
- 015-平衡二叉树(一)
- 二叉查找树的综合应用
- System io statistics
- Scrapy + Selenium implements simulated login and obtains dynamic page loading data
- MySQL的分页你还在使劲的limit?
- redis实现分布式锁的原理
- Rabbit and Falcon are all covered, Go lang1.18 introductory and refined tutorial, from Bai Ding to Hongru, the whole platform (Sublime 4) Go lang development environment to build EP00
猜你喜欢
随机推荐
php中去重二维数组
"Easy to use" websites that others don't know, make you more efficient
MySql的初识感悟,以及sql语句中的DDL和DML和DQL的基本语法
Redis和MySQL如何保持数据一致性
关于GBase 8c数据库的问题,如何解决?
flush tables
面试突击71:GET 和 POST 有什么区别?
ClickHouse查询语句详解
【字节面试】word2vector输出多少个类别
RSTP(端口角色+端口状态+工作机制)|||| 交换机接口分析
What are pseudo-classes and pseudo-elements?The difference between pseudo-classes and pseudo-elements
函数指针数组
R语言ggplot2可视化数据点重合的散点图、数据点有重合、使用geom_smooth函数基于lm方法拟合数据点之间的趋势关系曲线、自定义数据点的大小、色彩、添加主标题、副标题、题注信息
梯度消失和梯度爆炸
milvus
Cartesi 2022 年 7 月回顾
STP和RSTP的BPDU报文中flag位 对比+分析
慢 SQL 分析与优化
10 Convolutional Neural Networks for Deep Learning 2
MySQL_关于JSON数据的查询