Problems > Diameter of the Point Set > Editorial

Diameter of the Point Set — Solution & Editorial

Back to the Problem

The farthest pair are both hull vertices. Build the convex hull, then rotating calipers finds the diameter in O(hull size).

Complexity: O(N log N)

Watch out: Squared distances reach ~8×1012 — 64-bit; and checking only hull points is essential (interior points are never farthest).