Common Free Time Across Every Teammate's Calendar

Last updated: November 29, 2026

Quick Overview

Each teammate has a sorted list of non-overlapping busy intervals. Return the finite intervals during which everyone is free, in sorted order.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Each teammate has a sorted list of non-overlapping busy intervals. Return the finite intervals during which everyone is free, in sorted order.

A Google onsite question drawn straight from Google Calendar's find-a-time feature. The interviewer checks the k-way merge of sorted schedules with a heap and the gap detection between merged busy blocks.

What the Interviewer Expects
  • Uses a heap to merge k sorted lists by start time
  • Tracks the latest busy end seen so far
  • Emits a gap whenever the next start exceeds that end
  • Returns only finite gaps
  • States O(N log k)
Key Topics to Cover
Heap
K-Way Merge
Intervals
Calendars
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Only return gaps of at least 30 minutes
  • Restrict to working hours in each person's time zone
  • Find times when at least k - 1 of k people are free
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list of k schedules, each a sorted list of non-overlapping (start, end) intervals.
  • Output: sorted list of (start, end) intervals with positive length where nobody is busy, between the f...
High-Level Design

Everyone is free exactly in the gaps of the union of all busy intervals. Because each schedule is already sorted, a k-way merge with a heap yields all intervals in start order without a full sort.

Se...


Submit Your Answer
Markdown supported