Getting tle in this ques

You have used a min heap for this problem. Using a max heap will be more efficient. Just think about it and try using a max heap.
So, maintain a k sized max heap…if size of heap becomes > k pop the top element…the top element at any moment will be the kth nearest distance…