Discussion :: Data Structure MCQs
- Making the pop operation costly, select the code snippet which implements the same.
Answer : Option C
Explanation :
Here the pop operation is costly, hence we need two queues, other than the first element, all the the elements from one queue are dequeued and enqueued to the second queue, hence only one element remains in the first queue which is the item we want, so dequeue it and return the result.
Be The First To Comment