FunctionRacerProblemsRace

Nearest Point to Each Query

MediumSciPyPython

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More SciPy problems