当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
AUC的两种计算方式
Automated test browser driver download version
ClickHouse查询语句详解
go版本升级
机器学习(公式推导与代码实现)--sklearn机器学习库
Go Redis database operation
php中去重二维数组
【LeetCode】622. Design Circular Queue
Unity笔记之简陋的第一人称漫游
SQL教程之递归 CTE Common Table Expression
mysql8安装步骤教程
MySQL——几种常见的嵌套查询
多媒体数据处理实验1:算术编码
pytorch installation error
oracle中的rownum函数
STP生成树选举结果查看及验证
scala减少,reduceLeft reduceRight,折叠,foldLeft foldRight
CRT command keys
Go的Gin框架学习
MYSQL 修改时区的几种方法









