Earliest Common Meeting Slot of a Given Length for Two Calendars

Last updated: November 29, 2026

Quick Overview

Given two people's free time slots in Google Calendar, each a list of non-overlapping [start, end] intervals, and a meeting duration, return the earliest [start, start + duration] slot that fits in both, or an empty list.

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

0

0

0 solved


Given two people's free time slots in Google Calendar, each a list of non-overlapping [start, end] intervals, and a meeting duration, return the earliest [start, start + duration] slot that fits in both, or an empty list.

A Google onsite question grounded in Calendar's find-a-time feature. The interviewer checks sorting each list, walking two pointers over intervals, computing overlaps correctly, and advancing the interval that ends first.

What the Interviewer Expects
  • Sorts both lists by start time
  • Computes overlap as max of starts and min of ends
  • Advances the interval that ends first
  • Returns the earliest fit and stops
  • Handles touching intervals and zero-length overlaps
Key Topics to Cover
Two Pointers
Intervals
Sorting
Calendar Scheduling
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
  • Generalize to k attendees.
  • What if you need every slot of the given duration, not just the earliest?
  • How would you handle time zones and working-hours constraints?
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: a and b, lists of [start, end] with start < end, non-overlapping within each list but not necessarily sorted; integer duration > 0.
  • Output: [s, s + duration] for the earliest `s...
High-Level Design

Sort both lists by start. Use pointer i into a and j into b. The overlap of the current two slots is [max(a_start, b_start), min(a_end, b_end)]. If its length is at least duration, return ...


Submit Your Answer
Markdown supported