Getting TLE in one test case

@mohammadabdullahjawwad you need to use a max heap of size k to store the distances, pop the top element if a smaller distance is found, and top will also give the kth farthest distance because it will be the maximum element in the heap of size k.

Now that second test case is altogether wrong!

@mohammadabdullahjawwad in your dist() function the datatype for x and y are int, change it to ll

Thanks! It worked :slight_smile:

1 Like

@mohammadabdullahjawwad please mark the doubt as resolved :slight_smile:

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.