Smallest Most-Lit Street Position
Problem statement
A streetlight centered at positions[i] with radius radii[i] illuminates every integer position from positions[i] - radii[i] through positions[i] + radii[i], inclusive.
Return the smallest integer position illuminated by the maximum number of streetlights.
Function
mostLitPosition(positions: int[], radii: int[]) → intExamples
Example 1
positions = [0,5]radii = [2,3]return = 2The two inclusive intervals overlap only at position 2.
Example 2
positions = [1,4,7]radii = [3,0,3]return = 4All three streetlights illuminate position 4.
Example 3
positions = [0,10]radii = [1,1]return = -1The maximum coverage is one in two disjoint intervals, so the smallest covered position is -1.
Constraints
1 <= positions.length = radii.length <= 200000.-10^8 <= positions[i] <= 10^8.0 <= radii[i] <= 10^8.