Compute shared free time intervals
Problem: Compute Shared Free Time Intervals
You are given schedules for multiple employees. schedules[i] is a list of busy intervals for employee i, where each interval is half-open [start, end) in minutes from 0 to 1440 for a single day.
Return all maximal half-open intervals [s, e) during which every employee is free.
Requirements:
- Input may contain up to 10^4 total intervals across all employees.
- Intervals within an employee's schedule may be unsorted and may overlap; you must normalize as needed.
- Output intervals must be sorted, non-overlapping, and strictly within the
[0, 1440)range.
Sub-questions:
- How would you handle schedules provided as strings like "09:30-12:00" and mixed time zones?
- How would you extend the solution to multiple days?
- How would you extend the solution to streaming updates to schedules?
- Discuss the time and space complexity and the data structures you would choose.
AI interview prep
Core dilemma
Efficiently aggregating and inverting a potentially large number of overlapping intervals from multiple sources, while correctly handling half-open intervals, edge cases, and scaling constraints.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Compute shared free time intervals
Problem: Compute Shared Free Time Intervals
You are given schedules for multiple employees. schedules[i] is a list of busy intervals for employee i, where each interval is half-open [start, end) in minutes from 0 to 1440 for a single day.
Return all maximal half-open intervals [s, e) during which every employee is free.
Requirements:
- Input may contain up to 10^4 total intervals across all employees.
- Intervals within an employee's schedule may be unsorted and may overlap; you must normalize as needed.
- Output intervals must be sorted, non-overlapping, and strictly within the
[0, 1440)range.
Sub-questions:
- How would you handle schedules provided as strings like "09:30-12:00" and mixed time zones?
- How would you extend the solution to multiple days?
- How would you extend the solution to streaming updates to schedules?
- Discuss the time and space complexity and the data structures you would choose.