Trains the technique from
LeetCode 2021Brightest Position on StreetThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A walkway is marked off with whole-number coordinates that run in both directions from zero. Lamps are described by lights, where lights[i] = [position_i, range_i] means lamp i stands at coordinate position_i and throws light on every whole-number coordinate from position_i - range_i through position_i + range_i, both ends included.
The brightness of a coordinate is the number of lamps whose light reaches it. Return the coordinate with the greatest brightness. If several coordinates share the greatest brightness, return the smallest of them.
Example 1
The first lamp lights 2 through 6, the second lights 4 through 8 and the third lights only 5. Coordinate 5 is reached by all three, so its brightness is 3 and no coordinate can beat that.
Example 2
One lamp lights -2 through 2 and the other lights 2 through 6. Coordinate 2 is the only one reached by both, so its brightness is 2.
Example 3
The lamps light -1 through 1 and 2 through 4, and they never overlap, so the greatest brightness is 1 and it is shared by six coordinates. The smallest of them is -1.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def brightest_position(lights: list[list[int]]) -> int:public int brightestPosition(int[][] lights)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.