Current streak:
0 days
Longest streak:
26 days
Less
More
#include <bits/stdc++.h> class Queue { int *arr; int Front; int back; int n = 1000; public: Queue() { // Implement the Constructor arr = new int[n]; Front = -1; back = -1; }
/*----------------- Public Functions of Queue -----------------*/
bool isEmpty() { // Implement the isEmpty() function if(Front == -1 || Front > back){ return true; } return false; }
void enqueue(int data) { // Implement the enqueue() function if(back == n-1){ return; } back++; arr[back] = data; if(Front == -1){ Front++; } }
int dequeue() { // Implement the dequeue() function if(Front == -1 || Front > back){ return -1; } int ele = arr[Front]; Front++; return ele; }
int front() { // Implement the front() function if(Front == -1 || Front > back){ return -1; } return arr[Front]; } };