← Microsoft Interview Insights

Microsoft·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Apr 2026

Summary

Microsoft SWE interview with a calendar scheduling problem. Pretty standard coding round, nothing too wild, but the I/O format tripped me up more than the logic itself.

Questions Asked (1)

Q1

Given a list of existing non-overlapping calendar events, determine whether a new event can be added without overlapping any of them. Implement using standard input/output.

Algorithms & Data Structures
Author's notes

The core logic isn't bad once you think about it as an interval overlap check.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the existing events are sorted by start time, then iterate through them to check for overlap with the new event. If any overlap is found, return false; otherwise, return true. For the implementation, read the input, parse the events and new event, and output the result.

Pro tip: Mention that if the events are not sorted, you can sort them first in O(n log n) time, but if they are already sorted, a linear scan is optimal. Also, discuss edge cases like events that touch at endpoints (e.g., one ends at 10 and another starts at 10) are not considered overlapping.

1. Clarify assumptions and input format

Ask whether the existing events are sorted by start time and confirm the definition of overlap (e.g., whether touching endpoints count). Understand the input format: number of events, each with start and end times, followed by the new event's start and end.

2. Choose the appropriate algorithm

If events are sorted, use a linear scan to check for overlap with the new event. If not sorted, either sort them first or use a more efficient interval tree if many queries are expected.

3. Implement the overlap check

For each existing event, check if the new event overlaps: newStart < existingEnd && newEnd > existingStart. If any overlap is found, return false; otherwise, return true.

4. Handle input/output and edge cases

Read input from standard input, parse the events, and output 'true' or 'false'. Consider edge cases: empty event list, new event completely before or after all events, and events that touch at endpoints.

5. Test and verify

Walk through a few test cases mentally or verbally to ensure correctness, including cases with no overlap, partial overlap, and complete containment.

Key Points to Mention

  • Time complexity: O(n) if events are sorted, O(n log n) if sorting is needed.
  • Space complexity: O(1) extra space for the check, aside from input storage.
  • Overlap condition: newStart < existingEnd && newEnd > existingStart.
  • Edge case: events that touch at endpoints (e.g., end == start) are not overlapping.
  • Input parsing: read number of events, then each event's start and end, then the new event's start and end.
  • Output: print 'true' if the new event can be added, 'false' otherwise.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.