Employee Free Time
Updated
Problem statement
A team wants to know when every employee is free on the same day. Every time is a number of minutes after midnight, and the day runs from minute 0 to minute 1440 (the next midnight).
You are given schedule, where schedule[i] lists the busy slots of employee i. A slot [start, end] means the employee is busy from minute start up to minute end. One employee's slots can come in any order, and they may overlap or touch.
Return every stretch of the day when no employee is busy, as a list of [start, end] pairs sorted by start. Each stretch must be as long as possible and have positive length, so a slot that ends at minute t and a slot that starts at minute t leave no free time between them. If there is no minute when everyone is free, return an empty list.
Function
employeeFreeTime(schedule: int[][][]) → int[][]Examples
Example 1
schedule = [[[540,600],[660,720],[900,960]],[[570,690],[930,1020],[1020,1050]]]return = [[0,540],[720,900],[1050,1440]]Nobody is busy before minute 540, so [0,540] is free. From 540 to 720 someone is always busy: employee 0's slot [540,600] overlaps employee 1's slot [570,690], which overlaps employee 0's slot [660,720]. Everyone is free from 720 to 900. From 900 to 1050 someone is busy again, and employee 1's slots [930,1020] and [1020,1050] touch, so no free time lies between them. After minute 1050 everyone is free until 1440.
Example 2
schedule = [[[0,300],[1200,1440]],[[240,1260]]]return = []Employee 0 is busy from 0 to 300 and from 1200 to 1440, and employee 1 is busy from 240 to 1260, which covers the gap between them. Someone is busy at every minute of the day, so the answer is empty.
Example 3
schedule = [[[600,660]],[],[[480,540],[500,520]]]return = [[0,480],[540,600],[660,1440]]Employee 1 has no busy slots, so they never block a free stretch. Employee 2's slot [500,520] lies inside their own slot [480,540]. The busy times are 480 to 540 and 600 to 660, so the free stretches are [0,480], [540,600] and [660,1440].
Constraints
1 <= schedule.length <= 500 <= schedule[i].length <= 50schedule[i][j].length == 20 <= schedule[i][j][0] < schedule[i][j][1] <= 1440
More Zillow Phone Screen questions
- Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
- Time Based Key-Value StorePHONE SCREEN · Seen Feb 2024
- Filter Formatted Records by CriteriaPHONE SCREEN · Seen Sep 2023
- Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
- Jump GamePHONE SCREEN · Seen Dec 2022
- Reversible Run-Length EncodingPHONE SCREEN · Seen Nov 2022
- Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
- Two Sum: All PairsPHONE SCREEN · Seen Nov 2022
- First Unique Character in a StringPHONE SCREEN · Seen Oct 2022
- K-th Smallest Number in a StreamPHONE SCREEN · Seen Oct 2022
Similar questions at other companies
- Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
- Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
- Meeting Rooms IIByteDance · PHONE SCREENByteDance interview questions
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN
- Meeting Rooms IIUber · PHONE SCREENUber interview questions
- Merge IntervalsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Merge Overlapping IntervalsFurtherAI · PHONE SCREEN
- Peak Resource Usage Across Weighted IntervalsTekion · PHONE SCREENTekion interview questions