Skip to content
DeepForgeby svx
All problems
MediumData Structuresds-229

Interval Tree Point Query

Problem

Check whether points fall inside any interval.

intervals is a list of [start, end] inclusive intervals and points is the list of query values. A point is covered when it lies within at least one interval.

Return a list of booleans.

Hint

Intervals are inclusive on both ends.

Test cases

case 1
in: [[[1,3],[5,7]],[2,4,6]]
expected: [true,false,true]
case 2
in: [[],[1]]
expected: [false]
case 3
in: [[[1,1]],[1,2]]
expected: [true,false]
case 4
in: [[[10,20]],[5,15,25]]
expected: [false,true,false]
Starter codePython
def interval_point_query(intervals, points):
    # Your code here
    pass

4 test cases · run your code against them in the editor