同步操作将从 七楼/JavaStudy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
class MyCircularQueue {private int[] data;private int headIndex;private int tailIndex;private int capacity;/** Initialize your data structure here. Set the size of the queue to be k. */public MyCircularQueue(int k) {capacity = k;data = new int[capacity];for (int i = 0; i < capacity; ++i)data[i] = -1;}/** Insert an element into the circular queue. Return true if the operation is successful. */public boolean enQueue(int value) {if (isFull())return false;data[tailIndex] = value;tailIndex = getNextIndex(tailIndex);return true;}/** Delete an element from the circular queue. Return true if the operation is successful. */public boolean deQueue() {if (isEmpty())return false;data[headIndex] = -1;headIndex = getNextIndex(headIndex);return true;}/** Get the front item from the queue. */public int Front() {return data[headIndex];}/** Get the last item from the queue. */public int Rear() {return data[getPrevIndex(tailIndex)];}/** Checks whether the circular queue is empty or not. */public boolean isEmpty() {return data[headIndex] == -1;}/** Checks whether the circular queue is full or not. */public boolean isFull() {return data[tailIndex] == -1;}private int getNextIndex(int currentIndex) {return currentIndex + 1 == capacity ? 0: currentIndex + 1;}private int getPrevIndex(int index) {return index == 0 ? capacity - 1: index - 1;}}/*** Your MyCircularQueue object will be instantiated and called as such:* MyCircularQueue obj = new MyCircularQueue(k);* boolean param_1 = obj.enQueue(value);* boolean param_2 = obj.deQueue();* int param_3 = obj.Front();* int param_4 = obj.Rear();* boolean param_5 = obj.isEmpty();* boolean param_6 = obj.isFull();*/
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。