# 0622. Design Circular Queue ###### tags: `Leetcode` `Microsoft` `Medium` ## Code ```java= class MyCircularQueue { int[] arr; int front=0, rear=-1, len=0; public MyCircularQueue(int k) { arr = new int[k]; } public boolean enQueue(int value) { if(!isFull()){ rear = (rear+1)%arr.length; arr[rear] = value; len++; return true; } return false; } public boolean deQueue() { if(!isEmpty()){ front = (front+1)%arr.length; len--; return true; } return false; } public int Front() { if(!isEmpty()){ return arr[front]; } return -1; } public int Rear() { if(!isEmpty()){ return arr[rear]; } return -1; } public boolean isEmpty() { return len==0; } public boolean isFull() { return len==arr.length; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up