Loading repovive.com/problems/classics/43
Given n points in the 2D plane with integer coordinates, find the minimum squared Euclidean distance between any pair of distinct points.
The squared distance between points (x1,y1) and (x2,y2) is (x1−x2)2+(y1−y2)2.
3 0 0 3 4 1 1
The closest pair is
(0, 0)
and
(1, 1)
, with squared distance 1 + 1 = 2.
2
4 0 0 5 0 3 0 8 0
All points lie on one line. The closest pair is at coordinates 3 and 5, giving squared distance 4.
4
5 0 0 10 0 10 10 0 10 5 5
The center point
(5, 5)
is closest to each corner, and that squared distance is 25 + 25 = 50.
50