In a Meta-style ranking or retrieval pipeline, you may need to quickly keep only the nearest candidate embeddings or coordinates. Given a list of points on a 2D plane, return the k points closest to the origin (0, 0).
The distance between a point (x, y) and the origin is sqrt(x^2 + y^2). For efficiency, compare points using squared distance x^2 + y^2 instead of computing square roots. You may return the answer in any order.
points: a list of 2-element lists, where each element is [x, y]k: an integerk points from points with the smallest distances to the origindef k_closest_points(points, k):