Problem · Intervals

Lamps and Control Points

Learn this problem
MediumZipRecruiter logoZipRecruiterOA

Problem 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

More ZipRecruiter problems

drafts saved locally
public int[] lampAndControlPoints(int[][] lamps, int[] points) {
  // write your code here
}
lamps[[1, 7], [5, 11], [7, 9]]
points[7, 1, 5, 10, 9, 15]
expected[3, 1, 2, 1, 2, 0]
checking account