Merge overlapping weekly time intervals
Problem Description
You are given a list of time intervals representing meetings. Each interval is a pair of strings in the format:
"<Day> <H>:<MM>"(24-hour time)<Day>is one ofMon, Tue, Wed, Thu, Fri, Sat, Sun- Examples:
"Mon 9:00","Mon 13:00","Tue 09:30"
Example input:
[["Mon 9:00", "Mon 13:00"], ["Mon 11:00", "Mon 16:00"]]
Two intervals overlap if they occur on the same day and their time ranges intersect (endpoints may be treated as overlapping, i.e., [9:00, 13:00] overlaps [13:00, 14:00]).
Task
- Parse the strings into comparable time values.
- Merge all overlapping intervals (per day) and return the merged list.
Output Requirements
- Return intervals in the same string format.
- Sort output by day-of-week (Mon→Sun), then by start time.
Assumptions
- All intervals start < end.
- Intervals may span different days, but each individual interval’s start and end are on the same day.
- Input size can be large enough that an efficient solution is expected (better than
O(N^2)).
AI interview prep
Core dilemma
Efficiently parsing and converting custom time string formats into comparable values, then applying a robust interval merging algorithm while respecting daily grouping and specific sorting requirements.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Merge overlapping weekly time intervals
Problem Description
You are given a list of time intervals representing meetings. Each interval is a pair of strings in the format:
"<Day> <H>:<MM>"(24-hour time)<Day>is one ofMon, Tue, Wed, Thu, Fri, Sat, Sun- Examples:
"Mon 9:00","Mon 13:00","Tue 09:30"
Example input:
[["Mon 9:00", "Mon 13:00"], ["Mon 11:00", "Mon 16:00"]]
Two intervals overlap if they occur on the same day and their time ranges intersect (endpoints may be treated as overlapping, i.e., [9:00, 13:00] overlaps [13:00, 14:00]).
Task
- Parse the strings into comparable time values.
- Merge all overlapping intervals (per day) and return the merged list.
Output Requirements
- Return intervals in the same string format.
- Sort output by day-of-week (Mon→Sun), then by start time.
Assumptions
- All intervals start < end.
- Intervals may span different days, but each individual interval’s start and end are on the same day.
- Input size can be large enough that an efficient solution is expected (better than
O(N^2)).