Hostel Visit Problem

Can you please explain the sample output given in the code.
For the first and the second queries it is taking the farthest distance whereas for the last query it is taking the 2nd farthest distance. Can you please explain the output?

You always have to give 3rd nearest distance.
For first query, you have (200,162,128) in the bank which gives 200.
For second query, you have (200,162,128,98 in the bank). So you give 162 as answer.
For third query you have (200,162,128,98,72,50) in the bank, so you give 98 as the annswer.

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.