GitHunt
MJ

mj-z-ali/K-Nearest-Coordinates-to-Origin-PY

K-Nearest-Coordinates-to-Origin-PY

We have a list of points on the plane. Find the K closest points to the origin (0, 0).

(Here, the distance between two points on a plane is the Euclidean distance.)

Points:

(-2, -4), (0, -2), (-1, 0), (3, -5), (-2, -3), (3, 2), (11, 2), (8, 0), (4, 5), (15, 2), (9, -9), (0,0)

Output:

[(0, 0), (-1, 0), (0, -2), (-2, -3), (3, 2)]