A map widget draws street lamps along a very long street. Lamp [position, range] lights every whole-number position from position - range to position + range, both included. Positions can be as far apart as hundreds of millions.
Write brightestSpot(lamps) that returns the smallest position lit by the largest number of lamps.
Input: lamps = [[2,3],[6,1],[9,2]] Output: 5
The lamps light [-1, 5], [5, 7], and [7, 11]. Positions 5 and 7 each get two lamps; 5 is smaller.
Input: lamps = [[0,0]] Output: 0
One lamp lights only position 0.
1 <= lamps.length <= 10^5-10^8 <= position <= 10^80 <= range <= 10^8Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #59 Brightest Spot on the Street. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.