Interval List Intersections

Try to solve the Interval List Intersections problem.


For two arrays of closed intervals given as input, intervalsA and intervalsB, 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 [3,8][3, 8] and [5,10][5, 10] is [5,8][5, 8].


  • 00 \leq intervalsA.length, intervalsB.length 1000\leq 1000

  • 00 \leq start[i] << end[i] 109\leq 10^9, where ii is used to indicate intervalsA

  • end[i] << start[i + 1]

  • 00 \leq start[j] << end[j] 109\leq 10^9, where jj is used to indicate intervalsB

  • end[j] << start[j + 1]


Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy