Problem · Intervals
Lamps and Control Points
Learn this problemProblem statement
Several lamps are placed on a number line. The ith lamp illuminates the inclusive segment from lamps[i][0] to lamps[i][1].
You are also given an array of control points. For each points[j], count how many lamp segments contain that point.
Return an integer array in which the jth value is the number of lamps that illuminate points[j].
Function
lampAndControlPoints(lamps: int[][], points: int[]) → int[]Examples
Example 1
lamps = [[1, 7], [5, 11], [7, 9]]points = [7, 1, 5, 10, 9, 15]return = [3, 1, 2, 1, 2, 0]n/a