Closest Pair of Points
Closest Pair of Points
Given a list of points [x, y], return the minimum squared Euclidean distance between any two distinct points.
Function signature
func ClosestPairDistance(points [][]int) int64
Example
points = [[0,0],[3,4],[7,7],[1,1]]
output = 2
Constraints
- 0 <= len(points) <= 200_000
- -1_000_000_000 <= x, y <= 1_000_000_000
Notes
- Use divide-and-conquer in O(n log n).
- Return squared distance to avoid floating point.
Run tests to see results
No issues detected