A stack is used to implement a priority queue
Means that our data structure must behave like a (priority) queue, but the internal mechanism of it is stack.
A task having higher priority would get processed first.
=> In the stack, higher the priority, closer to the top it'll be, because LIFO.
So, elements in the stack are in the order: (1,0),(45,1),(32,5),(100,6).
We have to insert (2,0) which has 0 priority.
If we just insert it, stack would look like: (1,0),(45,1),(32,5),(100,6),(2,0)
Then (2,0) would be processed first, which violates priorities.
So, we need to pop off priorities greater than 0 first. Pop 3 elements, then stack looks like.
(1,0),(45,1),(32,5),(100,6)
=> (1,0)
Now, contents of the stack and (2,0) have equal priority. Since our DS behaves like a queue overall... For equal priority, FIFO property of queue should hold.
=> We gotta pop (1,0) as well.
So, in all, we have to pop off 4 elements to push in (2,0).
This really can be solved under 30 seconds if you know the basics.