Employee Free Time

Hard
ArrayIntervalsSortingPremiumGoogleMeta
Each employee has a sorted list of busy intervals. Print finite intervals where every employee is free. Input format: - First line: m, the number of employees - For each employee: one line k, followed by k lines of start end busy intervals Intervals are half-open. Print common free intervals sorted by start, one per line as `start end`. Print `EMPTY` if there are no finite common free intervals.

Constraints

1 <= m <= 10^5
0 <= total intervals <= 10^5
-10^9 <= start <= end <= 10^9
Intervals for each employee are sorted and non-overlapping.

Sample tests

Sample 1

Sample 2

Sign in to submit