Nearest Point to Each Query
Each row of points and of queries is a point. Return, for each query, the row number of the point nearest to it. No query has two nearest points.
Example 1
points [[0,0],[10,10],[5,0]]
queries [[1,1],[9,8],[4,1]]
returns [0,1,2]
(1, 1) is nearest the origin, (9, 8) nearest (10, 10), and (4, 1) nearest (5, 0).
Constraints
1 <= len(points) <= 601 <= len(queries) <= 30- 2 or 3 columns
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More SciPy problems
- Range for the MeanMedium
- Two Groups ComparedMedium
- Where It Crosses ZeroMedium
- Chains of Close PointsHard
- Fish in the LakeHard
- Fit the Growth CurveHard
- Implied VolatilityHard
- Most Profit PlanHard