@habibkhan, Please check these lines again -
For push operation of stack , we simply enqueue into that queue which is not empty.
For pop operation , in any case , we do the following :
a) Dequeue all elements from the queue which is non empty and enqueue into the empty queue.
b) Then dequeue the front element from the queue where enqueue has been performed recently.
Let us do enqueue - 1, 2, 3, 4, 5
Now in the first line you said that we simply enqueue into that queue which is not empty, in the begning we will aways have an empty quueue .. right ??
Now, In cae of pop, you said that Dequeue all elements from the queue which is non empty and enqueue into the empty queue.
Lets say, q1 contains - 1, 2, 3, 4 and q2 is empty.
After doing the first operation for pop, q2 = 1, 2, 3, 4 and q1 will become empty ... right ??
Now, In the 2nd operation for pop you said that, Then dequeue the front element from the queue where enqueue has been performed recently, and I think it will return 1 right ?? but it should return 4, because it was the last element which was inserted into the queue in the last push operation ... right ??