My code keeps on giving segmentation fault.
Question: HOSTEL VISITS(STL)
Code: https://ide.geeksforgeeks.org/SBc81d6vA6
Segmentation fault
- you are making a new priority queue for each query, so for every query, you will begin with a new empty queue and this is why query of type 2 will end up giving a segmentation fault. So declare the queue outside while loop and it will run fine.
- print answer for each query in a new line.
Code with changes: https://ide.geeksforgeeks.org/YJ4IRIxhCv
Please mark your doubt as resolved.
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.