ByteByteGo logo
menuProblems List

Identify All Interval Overlaps

Medium

Return an array of all overlaps between two arrays of intervals; intervals1 and intervals2. Each individual interval array is sorted by start value, and contains no overlapping intervals within itself.

Example:

Input: intervals1 = [[1, 4], [5, 6], [9, 10]],
       intervals2 = [[2, 7], [8, 9]]
Output: [[2, 4], [5, 6], [9, 9]]

Constraints:

  • For every index i in intervals1, intervals1[i].start < intervals1[i].end.

  • For every index j in intervals2, intervals2[j].start < intervals2[j].end.

You can practice coding exercises online by logging into bytebytego.com on your laptop.