Given an array of points where points[i] = [x_i, y_i] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two points on the X-Y plane is the Euclidean distance (i.e., sqrt((x1 - x2)^2 + (y1 - y2)^2)). You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in).
Example 1
Input: points = [[1,3],[-2,2]], k = 1
Output: [[-2,2]]
Explanation: The squared distances are 1² + 3² = 10 for (1,3) and 2² + 2² = 8 for (-2,2). The closer point is (-2,2).
Example 2
Input: points = [[3,3],[5,-1],[-2,4]], k = 2
Output: [[3,3],[-2,4]]
Explanation: The squared distances are 18 for (3,3), 26 for (5,-1) and 20 for (-2,4). The two smallest are (3,3) and (-2,4).
Example 3
Input: points = [[0,1],[1,0]], k = 2
Output: [[0,1],[1,0]]
Explanation: k = 2 equals the number of points, so both points are returned.
Keep a max-heap holding the k closest points seen so far, keyed by squared distance. When it exceeds k, pop the farthest. No need for actual square roots — comparing squared distances preserves order.
Run checks all cases above. Submit evaluates all test cases.