Single case giving TLE, please tell me where am i wrong.
Single Test case TLE
nearest distance will be lesser in value, why should I use a max heap instead of a min heap
This code uses max heap, still the same test case is giving TLE
@namangarg2000 getting TLE due to unnecessary operations, why are you making the size of heap more than k in the first place? I dont understand your logic at all, please elaborate.
I’ll explain the logic needed for max-heap
For t=1,
if size of heap < k, insert the distance
else, insert the distance only if it is < pq.top() {we are storing the k nearest distances in the heap}
for t=2
simply print pq.top()