Priority_queue as argument?

priority_queue as argument will not affect actual copy of priority queue.
is it take linear time for copying priority queue ?

and what after completion of function body it automatically removed ?

is any way to remove the element from priority_queue which are not useful or we need top k + 1 elements in priority queue ?

waiting for response …

You are thinking it right. Use Priority_queue as function parameter. ( Note: We need to keep elements that you pop, so passing by value is a good option)
Don’t worry, You wont face any TLE.
Please have a look at this short snippet.

1 Like

so we can pass any data structure as argument. it done by deepcopy and is always linear time complexity?

Yeahh
Send priority queue as arguement and get through the problem!

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.