Problem Β· Array

Lamps Illumination

Learn this problem
● EasyDatabricks logoDatabricksOA

Problem statement

Each row [left, right] in lamps is an inclusive illuminated interval on a number line.

For every value in points, count how many lamp intervals contain that point. Return the counts in the same order as points.

Function

solution(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]

Point 7 belongs to all three inclusive intervals. The remaining points are covered by 1, 2, 1, 2, 0 lamps respectively.

More Databricks problems

drafts saved locally
public int[] solution(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