Solution: Interval List Intersections
Let's solve the Interval List Intersections problem using the Merge Intervals pattern.
Statement
For two lists 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 lists.
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]
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.