Algorithm · Salesforce · Easy
You are given a collection of points on a 2D plane, each represented as a coordinate pair [x, y], and a positive integer k. Your task is to return the k points that are closest to the origin (0, 0). Distance is measured by the standard Euclidean metric: for a point [x, y], its distance to the origin is $$\sqrt{x^2 + y^2}$$. Since the ordering of points by distance is unchanged when you compare the squared distances (the square root is monotonic), you may use $$x^2 + y^2$$ as…
Checking your access…