pls tell what is wrong in this code for hostel visit and pls optimise it
Hostel visit doubt in code
@Tanna
Change your return type of dist( ) to long long int from int.
Your code seems to work fine in the appropriate time complexity. Just wanted to point out that you don’t even need to store x and y , just the distance. So you could simply make a heap of long long int distance and that would do the trick.
However , what you have done is fine as well.
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.