https://ide.codingblocks.com/s/229060…plz help with the code
I am not able to iterate through the priority queue
You can “iterate” through a priority queue only by popping it’s head until it’s empty.
modified code https://ide.codingblocks.com/s/229072
sir I did the same thing before , but it is showing TLE … and now also it is showing TLE error
okay
ya this may give TLE
as we need only k size priority queue and we are unneccesary making large size priority queue
so we have to remove extra elements
which is not possible in priority queue directly
so use multiset
it worked but can you plz tell me how you used erase function and thy did you put “r” in cout<<*distances.rbegin()
for erase read this documentation
http://www.cplusplus.com/reference/set/multiset/erase/
we use rbegin() (reverse iterator) because we have to erase element from last
i hope that your doubt is resolved by me
if you don’t have further doubt regarding this
please Mark you doubt as resolved from your doubt section in the course