Back to problems

K Closest Points

Algorithm · Uber · Medium

K Closest Points to Origin Medium · Topics · Company Tags · Hints You are given a list of points on a 2D plane, where each point is represented as [xi, yi]. You are also given an integer k. Return the k points that are nearest to the origin (0, 0). The distance between a point [x, y] and the origin is defined as $$x^{2} + y^{2}$$ (the squared Euclidean distance). You do not need to compute square roots. You may return the k closest points in any order. The answer is…

Checking your access…