Merge Two Interval Lists Problem

Merge Two Interval Lists Problem — ExecCode Easy DSA Practice

Solve the Merge Two Interval Lists problem on ExecCode. Free online easy DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given two lists of intervals, a and b, each individually sorted by start time (but possibly overlapping across the two lists), combine them into a single list and merge any intervals that overlap or touch, sorted by start time.

Examples

Input a = [[1, 2], [3, 4]], b = [[2, 3], [5, 6]]; Output [[1, 4], [5, 6]]. Input a = [[1, 5]], b = [[6, 10]]; Output [[1, 5], [6, 10]]. Input a = [], b = [[2, 4], [5, 7]]; Output [[2, 4], [5, 7]]

Constraints

0 ≤ a.length, b.length ≤ 10⁴ a[i].length == b[i].length == 2 0 ≤ starti ≤ endi ≤ 10⁵ each list is individually sorted by start time

Practice Merge Two Interval Lists free on ExecCode. Browse DSA problems, topic map, and placement guides.