622 Design Circular Queue | Leetcode | Java | Hindi Using Array

preview_player
Показать описание
Hey folks!
In this video, we discussed what is Circular queue with implementation using an array in Hindi using Java Language.
#00:10 Introduction
#00:10 Observation using Array
#08:46 Coding
#18:24 Debugging Important
# 22:00 Concluding words
P.S. I'll upload a video with the implementation of Data Structures.

622. Design Circular Queue

If you have any queries reach out to me at
Рекомендации по теме
Комментарии
Автор

Why have you stopped making Leetcode solution videos. Please start making videos again, you are doing a good work. Please, please, please

CodingJoySoul
Автор

Very nice explanation ! Thank you so <3

poorpanda
Автор

Thanks buddy for making such a nice solution video.

jitendrasoni_
Автор

// C++ 99%
class MyCircularQueue {
public:
int *data;
int front;
int rear;
int size;
int len;
MyCircularQueue(int k) {
data = new int[k];
size = 0;
front = -1;
rear = -1;
len = k;
}

bool enQueue(int value) {
if( isFull() ) return false;
if(size == 0) {
front = 0;
}
rear += 1;
rear = rear % len;
data[rear] = value;
size++;
return true;
}

bool deQueue() {
if( isEmpty() ) {
return false;
}
front+=1;
front = front % len;
size--;
if(size == 0) {
front = -1;
rear = -1;
}
return true;
}

int Front() {
if( isEmpty() ) return -1;
return data[front];
}

int Rear() {
if( isEmpty() ) return -1;
return data[rear];
}

bool isEmpty() {
return size == 0;
}

bool isFull() {
return size == len;
}
};

udyanishere
Автор

// JAVA:
class MyCircularQueue {

int[] data;
int front = -1;
int rear = -1;
int size = 0;

public MyCircularQueue(int k) {
data = new int[k];
}

public boolean enQueue(int value) {
if( isFull() ) return false;
if(size == 0) {
front = 0;
}
rear += 1;
rear = rear % data.length;
data[rear] = value;
size++;
return true;
}

public boolean deQueue() {
if( isEmpty() ) {
return false;
}
front+=1;
front = front % data.length;
size--;
if(size == 0) {
front = -1;
rear = -1;
}
return true;
}

public int Front() {
if(size == 0) return -1;
return data[front];
}

public int Rear() {
if(isEmpty()) return -1;
return data[rear];
}

public boolean isEmpty() {
// if(size == 0) return true;
// return false;
return size == 0;
}

public boolean isFull() {
return size == data.length;
}
}

udyanishere
join shbcf.ru