Insert a New Meeting Into a Sorted Outlook Busy Calendar
Last updated: November 29, 2026
Quick Overview
Given a list of non-overlapping busy intervals sorted by start and a new meeting interval, insert the meeting and merge as needed so the calendar stays sorted and non-overlapping, in a single linear pass.
Microsoft
November 29, 20260
0
0 solved
Given a list of non-overlapping busy intervals sorted by start and a new meeting interval, insert the meeting and merge as needed so the calendar stays sorted and non-overlapping, in a single linear pass.
An Outlook-flavored interval problem used in Microsoft onsites. The input is already sorted and disjoint, so the interviewer expects O(n) without re-sorting, and pays attention to clean handling of the three phases: before, overlapping, after.
What the Interviewer Expects
- Exploit the sorted, disjoint input instead of re-sorting
- Copy intervals ending before the new one starts
- Absorb all overlapping intervals into the new one
- Copy the remaining intervals
- Keep the pass linear and avoid off-by-one errors on touching edges
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you do this with binary search to find the overlap range?
- What if the calendar is stored in a balanced tree for frequent inserts?
- How would you remove a time range from the calendar instead?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: busy, a sorted list of disjoint [start, end], and new = [s, e]. Output: a new sorted disjoint list containing the union. Touching intervals merge, matching how Outlook shows back-to-back ...
High-Level Design
Three phases in one scan. Phase 1: while the current interval ends before s, it is unaffected, so append it. Phase 2: while the current interval starts at or before e, it overlaps the meeting, so ...