Return Finite Gaps Shared by Every Schedule

Quick Overview

Return Finite Gaps Shared by Every Schedule. schedule contains each employee's sorted, nonoverlapping working intervals.

Return Finite Gaps Shared by Every Schedule

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Other

### Problem schedule contains each employee's sorted, nonoverlapping working intervals. Return all finite, positive-length intervals during which everyone is free, in increasing order. Keep the native Interval objects with start/end fields in both input and output; [a,b] notation below only describes those objects. Omit unbounded outside time and zero-length gaps. ```cpp class Solution { public: vector<Interval> employeeFreeTime(vector<vector<Interval>> schedule); }; ``` ### Examples **Example 1:** ```text schedule = [[[1,3],[7,9]],[[2,5]]] Output intervals: [[5,7]] Explanation: Someone is busy throughout [1,5] and [7,9]. ``` **Example 2:** ```text schedule = [[[0,2]],[[2,4]]] Output intervals: [] Explanation: Touching work intervals leave no positive-length common gap. ``` ### Constraints - Employee count and intervals per employee are each between 1 and 50. - Each work interval has 0 <= start < end <= 100000000. - Each employee's intervals are sorted and do not overlap. ### Contract considerations Preserve `vector<vector<Interval>>` and `vector<Interval>`, with sorted finite outputs. ```hint Read the boundary condition When is a gap outside the union of every employee's work? ``` ### Boundary reminders Preserve `vector<vector<Interval>>` and `vector<Interval>`, with sorted finite outputs.

Overview: Return Finite Gaps Shared by Every Schedule. schedule contains each employee's sorted, nonoverlapping working intervals.

Google logo
Google
Source window: 0–3 months · as of Oct 21, 2026
hardSoftware EngineerOtherCoding & Algorithms
0
0

Problem

schedule contains each employee's sorted, nonoverlapping working intervals. Return all finite, positive-length intervals during which everyone is free, in increasing order. Keep the native Interval objects with start/end fields in both input and output; [a,b] notation below only describes those objects. Omit unbounded outside time and zero-length gaps.

class Solution {
public:
    vector<Interval> employeeFreeTime(vector<vector<Interval>> schedule);
};

Examples

Example 1:

schedule = [[[1,3],[7,9]],[[2,5]]]
Output intervals: [[5,7]]
Explanation: Someone is busy throughout [1,5] and [7,9].

Example 2:

schedule = [[[0,2]],[[2,4]]]
Output intervals: []
Explanation: Touching work intervals leave no positive-length common gap.

Constraints

  • Employee count and intervals per employee are each between 1 and 50.
  • Each work interval has 0 <= start < end <= 100000000.
  • Each employee's intervals are sorted and do not overlap.

Contract considerations

Preserve vector<vector<Interval>> and vector<Interval>, with sorted finite outputs.

Boundary reminders

Preserve vector<vector<Interval>> and vector<Interval>, with sorted finite outputs.