Algorithm · Capital One · Medium
Picture a street as a number line that extends without end in both directions. You receive a 2D integer array lights, in which each entry lights[i] = [positioni, rangei] describes a single lamp placed at positioni. That lamp lights up every point of the closed interval $$[position_i - range_i, \; position_i + range_i]$$, endpoints included. For any integer position on the street, its brightness equals how many lamps cover it. Find the maximum brightness reached anywhere, and…