Magicsheet logo

Count Days Without Meetings

Medium
12.5%
Updated 8/1/2025

Asked by 3 Companies

Count Days Without Meetings

What is this problem about?

The Count Days Without Meetings interview question gives you a total number of days days and an array of meeting intervals [[start, end]]. You need to count how many days have no meetings scheduled. Meetings can overlap, so you must first merge the intervals to find the total number of unique days that are "busy."

Why is this asked in interviews?

Microsoft, Amazon, and Google use the Sorting interview pattern for this problem because interval merging is a fundamental software engineering task. It evaluates whether you can handle overlapping ranges and boundary conditions. It’s a "Medium" difficulty task that tests your ability to clean up messy data before performing a calculation.

Algorithmic pattern used

The core pattern is Interval Merging.

  1. Sort the meeting intervals by their start time.
  2. Iterate through the sorted intervals and merge overlapping or adjacent ones. For example, [1, 3] and [3, 5] merge into [1, 5].
  3. Calculate the total number of busy days by summing (end - start + 1) for each merged interval.
  4. Total free days = total_days - total_busy_days.

Example explanation

Total Days: 10. Meetings: [[1, 3], [2, 4], [8, 8]]

  1. Sort meetings: [1, 3], [2, 4], [8, 8].
  2. Merge [1, 3] and [2, 4] -> [1, 4].
  3. Merged intervals: [1, 4] and [8, 8].
  4. Busy days: (4 - 1 + 1) + (8 - 8 + 1) = 4 + 1 = 5.
  5. Free days: 10 - 5 = 5. Result: 5.

Common mistakes candidates make

  • Not Sorting: Forgetting that interval merging only works if the intervals are processed in order of their start times.
  • Off-by-one: Using end - start instead of end - start + 1 to count the number of days in an inclusive interval.
  • Handling Gaps: Incorrectly calculating the space between merged intervals instead of subtracting the total busy days from the total count.

Interview preparation tip

Interval problems are extremely common. Practice the standard "Merge Intervals" template until you can write it flawlessly. It’s the foundation for many calendar and scheduling features.

Similar Questions