Hostel visit concept doubt

How the nearest distance can be 200, if the smallest distance is 128 for the first time when the queue is filled, shouldn’t we use min priority queue rather than max.
Because max is always going to give the largest distance from the dean and min is always going to give the smallest distance

It is asking for the Kth nearest distance.
In the sample test case k=3, distances are
128 , 162 , 200
now 2 is the the 3rd nearest hostel, which is our answer.(suppose we have sorted array in ascending order, kth nearest will be the element at position k)
I hope this clear your doubt regarding min max priority queue also.

ok so we have to find the " kth "nearest hostel distance from the dean?

@vikashkmr519 yes we need to find the kth nearest hostel

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.