TLE Exception Error

How can I optimize the code more to overcome TLE ?

Hi @exceptionXD
Use heap data structure to avoid TLE.
Keep on pushing distances to the heap. Whenever asked to find kth nearest hostel, temporarily pop k-1 distances to get your required hostel at the top. Push those k-1 distances back to the heap.

Hey , I am using Heap now still getting TLE , here is the link to my code

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.