Brightest Position on a Street
Problem statement
Each row [position, radius] in lights describes a street light at an integer coordinate. It illuminates every integer coordinate in the inclusive interval [position - radius, position + radius].
The brightness of a coordinate is the number of lights that illuminate it. Return the smallest coordinate having the maximum brightness.
Function
brightestPosition(lights: int[][]) → intExamples
Example 1
lights = [[-3,2],[1,2],[3,3]]return = -1Coordinate -1 is the smallest coordinate illuminated by the maximum of two lights.
Example 2
lights = [[1,0],[0,1]]return = 1Coordinate 1 is illuminated by both lights.
Constraints
1 <= lights.length <= 10^5lights[i].length == 2-10^8 <= position <= 10^80 <= radius <= 10^8