← 返回 google 的题目列表Find Common Available Time Slots in Google Calendar
类型:online_judge
Problem: Find Common Available Time Slots in Google Calendar
Given the busy schedules of n people in Google Calendar, where each busy interval is represented as a half-open interval [start, end) in minutes, a valid working window [workStart, workEnd), and a required meeting length duration.
Return all time intervals [start, end) where a meeting can be scheduled such that:
the interval is fully inside [workStart, workEnd);
no participant has a conflicting busy event;
the interval length is at least duration;
intervals are returned in ascending order by start time;
if no such interval exists, print None.
Input Format
n duration workStart workEnd
m1
start end
...
m2
start end
...
Where:
n is the number of participants;
the i-th participant has mi busy intervals;
all times are integer minutes;
busy intervals may be unsorted, overlapping, or adjacent.
Output Format
Print each available interval on a separate line:
start end
If no interval exists, print:
None
Constraints
1 <= n <= 10^5
Total number of busy intervals M <= 2 * 10^5
0 <= workStart < workEnd <= 10^9
1 <= duration <= workEnd - workStart
0 <= start < end <= 10^9
Example
Input:
2 30 540 1020
2
540 600
720 780
2
570 630
900 960
Output:
630 720
780 900
960 1020
Example
Input
2 30 540 1020
2
540 600
720 780
2
570 630
900 960
Output
630 720
780 900
960 1020