FastPrepLamps and Control Points

Lamps and Control Points

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA
Learn

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

See ZipRecruiter hiring insights
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…