FastPrepEmployee Free Time
Problems/Employee Free Time

Employee Free Time

IDFC Bank logoIDFC Bank● HardFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The author writes that "the interviewer said that I need to solve this problem for the 1st 20 minutes." The post links the LeetCode problem Employee Free Time. It adds that "they wanted full working code covering all edge cases within 20 minutes."

The report names the problem but does not repeat its rules, examples, or limits. Here, each employee's intervals are sorted and may touch but not overlap, touching intervals leave no free time, and you get the schedules as nested arrays of integer pairs.

The judged task matches the report at about 90%.

You are given the work schedules of several employees. schedule[i] is the list of time intervals when employee i is working. An interval [start, end] means the employee is busy from time start until time end.

Each employee's intervals are sorted by start time and do not overlap. One interval may end at the same time as the next one starts.

Find every stretch of time when all employees are free at the same time. Each free stretch must:

  • lie between two busy intervals. The open-ended time before the earliest start and after the latest end does not count.
  • have positive length. If one interval ends at time t and another starts at time t, there is no free time between them.
  • be as long as possible. It starts when the busy time before it ends and stops when the next busy time starts.

Return the free stretches as [start, end] pairs sorted by start time. If there is no common free time, return an empty array.

Function

employeeFreeTime(schedule: int[][][]) → int[][]

Examples

Example 1

schedule = [[[1,3],[8,10]],[[2,5]],[[9,12]]]return = [[5,8]]

Taken together, the employees are busy from 1 to 5 (intervals [1,3] and [2,5] overlap) and from 8 to 12 (intervals [8,10] and [9,12] overlap). Nobody works between 5 and 8.

Example 2

schedule = [[[0,2],[4,6],[10,11]],[[1,3],[7,8]]]return = [[3,4],[6,7],[8,10]]

The busy stretches are [0,3], [4,6], [7,8] and [10,11]. The gaps between them are [3,4], [6,7] and [8,10].

Example 3

schedule = [[[2,4],[4,7]],[[3,5]]]return = []

Employee 0 stops working at time 4 and starts again at time 4, so there is no gap there. Everyone is covered from 2 to 7, so there is no common free time.

Constraints

  • 1 <= schedule.length <= 50
  • 1 <= schedule[i].length <= 50
  • schedule[i][j].length == 2
  • 0 <= schedule[i][j][0] < schedule[i][j][1] <= 10^8
  • schedule[i][j][1] <= schedule[i][j + 1][0] for every employee i and every j with 0 <= j < schedule[i].length - 1

More IDFC Bank problems

  • Minimum Cake CutsOA · Seen Jul 2026
  • Smallest Adjacent ConcatenationOA · Seen Jul 2026
  • Find All People With SecretONSITE INTERVIEW · Seen Jul 2026
All IDFC Bank interview questionsSee IDFC Bank hiring insights
Saved
class Solution {
    public int[][] employeeFreeTime(int[][][] schedule) {
        // Write your code here.
    }
}
Checking account…