Two Closest Points
Each row of points is a point (x, y). Return [i, j] with i < j: the rows of the two points closest together. If pairs tie, return the pair with the smallest i, then the smallest j. No loops: for and while are not allowed.
Example 1
points [[0,0],[5,5],[1,1],[9,0]]
returns [0,2]
Points 0 and 2 are about 1.41 apart. No other pair is closer.
Constraints
2 <= len(points) <= 60- Coordinates are whole numbers from -50 to 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Vote of the NearestHard
- Above Average CountBeginner
- Average TemperatureBeginner
- Black and WhiteBeginner
- Celsius to FahrenheitBeginner
- Clip ScoresBeginner
- CorrelationBeginner
- Count DistinctBeginner