会议日程安排
Meeting Scheduler
题目详情
问题:会议日程安排
考察:数组、双指针、排序
来源:DSA Prep / Citadel
链接:https://leetcode.com/problems/meeting-scheduler
英文原题
Problem: Meeting Scheduler
Patterns: Array, Two Pointers, Sorting
Recency: 3mo
Link: https://leetcode.com/problems/meeting-scheduler
Source: https://www.dsaprep.dev/blog/citadel-coding-interview-questions/
解析
思路:分别按开始时间排序两个可用时间段列表,用双指针比较当前两段的交集。若交集长度至少 duration,返回最早交集;否则推进结束时间更早的一段。
复杂度:排序 O(m log m+n log n),扫描 O(m+n),空间 O(1) 到 O(log n)。
英文解析
Approach: Sort both availability lists and use two pointers. The overlap of the current two slots is `[max(starts), min(ends)]`; if its length reaches the duration, return it, otherwise advance the slot with the earlier end.
Complexity: Time , space after sorting.