Given an array of integer points [x, y], return the squared distance between the two closest points, as an integer.
- Two points at the same position are at distance
0 - Fewer than two points return
Infinity - Return the squared distance,
dx * dx + dy * dy; no square root is needed and the answer stays exact - Coordinates are integers up to
106 in absolute value - Do not change the input
- The all-pairs version is O(n²); aim for sorting by x and stopping each scan early, or for the guaranteed O(n log n) sweep or divide and conquer