Merge Weekly Time Intervals
Problem: Merge Weekly Time Intervals
You are given a list of time intervals, all occurring within a single week. Each timestamp is provided as a day-of-week followed by a 24-hour clock time (e.g., Sat 13:00 or Mon 09:30).
Each interval is represented as [start, end], where start and end are timestamps on the same weekly timeline, and it is guaranteed that start <= end.
Your task is to write a function that merges all overlapping intervals and returns the merged result in chronological order.
You should also explain your approach for parsing the weekday/time format into a comparable numeric value, and how you apply an efficient interval merging algorithm.
Example Input:
[Mon 09:00, Mon 11:00][Mon 10:30, Mon 12:00][Sat 13:00, Sat 14:00][Sat 13:30, Sat 15:00]
Example Output:
[Mon 09:00, Mon 12:00][Sat 13:00, Sat 15:00]
AI interview prep
Core dilemma
Efficiently converting custom weekly time strings into a comparable numeric format and then applying a standard interval merging algorithm while maintaining chronological order.
2 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Merge Weekly Time Intervals
Problem: Merge Weekly Time Intervals
You are given a list of time intervals, all occurring within a single week. Each timestamp is provided as a day-of-week followed by a 24-hour clock time (e.g., Sat 13:00 or Mon 09:30).
Each interval is represented as [start, end], where start and end are timestamps on the same weekly timeline, and it is guaranteed that start <= end.
Your task is to write a function that merges all overlapping intervals and returns the merged result in chronological order.
You should also explain your approach for parsing the weekday/time format into a comparable numeric value, and how you apply an efficient interval merging algorithm.
Example Input:
[Mon 09:00, Mon 11:00][Mon 10:30, Mon 12:00][Sat 13:00, Sat 14:00][Sat 13:30, Sat 15:00]
Example Output:
[Mon 09:00, Mon 12:00][Sat 13:00, Sat 15:00]