Find the nearest neighbour from a clicked point within a given radius
Asked in the DSA for UI stage. Given 2D integer points, a clicked coordinate, and a non-negative radius, return the index of the closest point whose Manhattan distance from the clicked point is at most the radius. Return -1 if no point qualifies. If multiple points are equally close, return the smallest index.
points is a list of [x, y] coordinates, clicked is [x, y], and radius is an integer. Return an integer index.
def nearest_neighbor(points, clicked, radius):