class Node {
private int data {get; set;}
public Node previous {get; set;}
public Node (int val)
{
data = val;
previous = null;
}
}
class Queue {
private Node Front, Rear, Prev = null;
public Queue()
{
Front = Rear = null;
}
public void Enque(int val)
{
Node n = new Node(val);
if (Prev == null)
{
Front = Rear = n;
}
else if (Front == Rear)
{
Rear.previous = n;
Front = Rear.previous;
}
else
{
Front.previous = n;
Front = Front.previous;
}
}
public int Deque()
{
int val = Rear.data;
Rear = Rear.previous;
return val;
}
}
I haven't tested this solution so test it before use. Also I did it in short amount of time so if you find any bugs or any other glitch, please let me know. Thanks.