循环队列

    xiaoxiao2025-03-12  57

    class MyCircularQueue { private int front; private int rear; private int[] elem; private int usedSize; private int DEFAULT_CAPACITY;//总共大小 /** Initialize your data structure here. Set the size of the queue to be k. */ public MyCircularQueue(int k) { this.elem = new int[k+1]; DEFAULT_CAPACITY = k+1; this.front = 0; this.rear = 0; } /** Insert an element into the circular queue. Return true if the operation is successful. */ public boolean enQueue(int value) { if(isFull()) { return false; } this.elem[this.rear] = value; this.rear = (this.rear+1)
    转载请注明原文地址: https://yun.8miu.com/read-136243.html
    最新回复(0)