You have a list of meetings in your calendar with a start and end time. You are very busy, so meetings can overlap.
You also have one “Do Not Schedule”(DNS) interval during which you don’t attend any meeting.
Any meeting schedule that overlaps with a DNS slot is automatically cut such that it does not overlap with the DNS slot anymore.
Return a list of non-overlapping time intervals when you are in a meeting.
Example diagram:
Meeting | ---- ------------- ---
| ---- -------- --
DNS: XXXX
---------------------------------------> t
RES: | ----- XXXX ----- --- --
Sample input (for simplicity, all intervals include the left point and exclude the right point):
Meetings: [(1, 7), (5, 10), (12, 30), (22, 30), (40, 50), (60, 70)]
DNS: (18, 25)
Sample output:
[(1, 10), (12, 18), (25, 30), (40, 50), (60, 70)]
Part 2
Now you have more than one DNS slot.
If DNS slots overlap, they are merged into one DNS slot; everything else works the same.
Return one list of non-overlapping time intervals when you’re busy with meetings,
and another list for the merged DNS intervals.
Sample input:
Meetings: [(1, 7), (5, 10), (12, 30), (22, 30), (40, 50), (60, 70)]
DNS: [(18, 25), (20, 28), (65, 75)]
Sample output:
Meetings: [(1, 10), (12, 18), (28, 30), (40, 50), (60, 65)]
DNS: [(18, 28), (65, 75)]
- 给定若干个会议时间区间(可能重叠)
- 给定一个或多个 DNS(不能开会)区间
- 如果会议与 DNS 重叠,会议会被自动切割,确保不与 DNS 交集
- 多个 DNS 区间要先 merge
- 输出:
- 处理后不重叠的会议区间列表
- 合并后的 DNS 区间列表(仅 Part 2)
核心思路:
- 先 merge DNS 区间
- 对每个会议区间与 DNS 做 subtract(区间差)
- 最后 merge 所有会议段落成为不重叠区间
VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 OpenAI、Google、Amazon、Citadel、SIG 等,提供实时答案助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备 Stripe 或类似工程向公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。