FastPrepBrightest Position on a Street

Brightest Position on a Street

Capital One logoCapital One● MediumNEW GRADFULLTIMEOA
Learn

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[][]) → int

Examples

Example 1

lights = [[-3,2],[1,2],[3,3]]return = -1

Coordinate -1 is the smallest coordinate illuminated by the maximum of two lights.

Example 2

lights = [[1,0],[0,1]]return = 1

Coordinate 1 is illuminated by both lights.

Constraints

  • 1 <= lights.length <= 10^5
  • lights[i].length == 2
  • -10^8 <= position <= 10^8
  • 0 <= radius <= 10^8

More Capital One problems

See Capital One hiring insights
public int brightestPosition(int[][] lights) {
  // write your code here
}
lights[[-3,2],[1,2],[3,3]]
expected-1
Checking account…