OJ题-设计循环队列(力扣)
题目: 思路: 不是每次都进行数字搬移(直到后面没空间了再一次性搬移到前面) //数组中实现对列 class MyCircularQueue { private int [ ] array ; //存储空间 private int size ; //当前数据个数 private int front ; //指向队首下标 private int rear ; //指向队尾下一个可用空间 /** Initialize your data structure here. Set the size of the queue to be k. */ public MyCircularQueue ( int k ) { //容量 array = new int [ k ] ; size = 0 ; front = 0 ; rear = 0 ; } /** Insert an element into the circular queue. Return true if the operation is successful. */ public boolean enQueue ( int value ) { //插入成功返回true if ( size == array . length ) { //满了不成功 return false ; } array [ rear ] = value ;