Skip to main content
LeetCode 2021, Medium. Topics: Array, Ordered Set, Prefix Sum, Sorting. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 18 parametrized pytest cases, and a playground notebook:

Problem

A perfectly straight street is represented by a number line. The street has street lamp(s) on it and is represented by a 2D integer array lights. Each lights[i] = [position_i, range_i] indicates that there is a street lamp at position position_i that lights up the area from [position_i - range_i, position_i + range_i] (inclusive). The brightness of a position p is defined as the number of street lamps that light up the position p. Given lights, return the brightest position on the street. If there are multiple brightest positions, return the smallest one.

Examples

Example 1

Constraints

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

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode All.
Last modified on September 7, 2026