FastPrepMinimum Euclidean Distance Between Points

Minimum Euclidean Distance Between Points

Luma AI logoLuma AI● HardFULLTIMEOA
Learn

Problem statement

Given Cartesian points in points, return the minimum Euclidean distance between two entries with different indices.

Function

minimumEuclideanDistance(points: int[][]) → double

Examples

Example 1

points = [[0,11],[-7,1],[-5,-3]]return = 4.47213595499958

The closest pair is (-7,1) and (-5,-3).

Constraints

  • 2 <= points.length <= 20000.
  • points[i].length == 2.
  • |points[i][j]| <= 10^7.
  • Results use absolute tolerance 1e-5.

More Luma AI problems

See Luma AI hiring insights
public double minimumEuclideanDistance(int[][] points) {
    // Return the closest distance between distinct indices.
}
points[[0,11],[-7,1],[-5,-3]]
expected4.47213595499958
Checking account…