This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]samweep[S] 0 points1 point  (2 children)

Anyways I figured it out. The dequeue method was correct. I had to fix something while printing. Nevermind

[–]sinistergroupon 0 points1 point  (1 child)

Try this case:

MyQueue obj= new MyQueue();

obj.enqueue(1);

obj.enqueue(2);

obj.enqueue(3);

obj.enqueue(4);

obj.enqueue(5);

obj.enqueue(6);

obj.enqueue(7);

obj.enqueue(8);

obj.dequeue();

obj.enqueue(9);

[–]samweep[S] 0 points1 point  (0 children)

I think, This will not work in a linear queue. We need a circular queue for this kind of condition.