Description

Given the schedules of multiple employees (each a list of non-overlapping intervals), find all common free time intervals when everyone is available.

Examples

Input:schedule = [[[1,2],[5,6]],[[1,3]],[[4,10]]]
Output:[[3,4]]
Explanation:

Common free time is [3,4].

Input:schedule = [[1]],[[1]],[[1]]]
Output:[1]
Explanation:

Minimal case with a single-element matrix.

Input:schedule = [[[1,3],[6,8]],[[2,4],[7,9]],[[5,6]]]
Output:[[4,5],[9,∞]]
Explanation:

Employee 1 works [1,3] and [6,8], Employee 2 works [2,4] and [7,9], Employee 3 works [5,6]. Merging all intervals: [1,4], [5,9]. The gaps between merged intervals are [4,5] (between first two employees' morning work and third employee's work) and [9,∞] (after all employees finish work).

Constraints

  • 1 ≤ schedule.length ≤ 50
  • 1 ≤ schedule[i].length ≤ 50

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!