Solution: Interval List Intersections
Let's solve the Interval List Intersections problem using the Merge Intervals pattern.
Statement
For two arrays of closed intervals given as input, intervalListA
and intervalListB
, where each interval has its own start and end time, write a function that returns the intersection of the two interval arrays.
For example, the intersection of and is .
Constraints
-
intervalListA.length
,intervalListB.length
-
start[i]
end[i]
, where is used to indicateintervalListA
-
end[i]
start[i + 1]
-
start[j]
end[j]
, where is used to indicateintervalListB
-
end[j]
start[j + 1]