How to iterate over priority queue

hello sir/mam
is there any way we can iterate over priority queue i dont want to pop from one and push other and again pop and push as it is costly operation please tell me is there any approach

Hey

We don’t have such iterators, insert and push are log (n) …if you want to do so use some other container. :slight_smile:

how can i used container can you give an example

U can use set to find the values in sorted order and u can iterate over it.