Back to Question

K Closest Points to Origin

Question Explain

Given an array of points on a 2D plane, find the $K$ closest points to the origin $(0, 0)$. Use a Max-Heap (Priority Queue) to maintain the $K$ smallest distances in $O(n \log k)$.

Start Trying This Question Simulation

Click "Start Speaking" and answer the question naturally.