← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given two lists of closed intervals, firstList and secondList. Each list is sorted by start time, and the intervals within the same list are pairwise disjoint.
Return all intersections between the two lists.
An intersection between [a, b] and [c, d] is [max(a, c), min(b, d)] when max(a, c) <= min(b, d).
Follow-up note: If the lists are too large to fit in memory, keep the same two-pointer logic but read each list as a stream or chunked iterator, buffering only the current interval from each source.
Reported for an Uber software engineer onsite round as a sorted-interval overlap problem, with a follow-up about handling input lists too large to fit in memory.