FastPrepSchedule Meeting

Schedule Meeting

Autodesk logoAutodesk● MediumFULLTIMEOA
Learn

Problem statement

A day contains minutes from 0 through 1440. For each employee, schedules[i] lists that employee's busy intervals. Every interval [start, end] occupies the half-open range [start, end).

Find the earliest minute at which a meeting of exactly length minutes can start while every employee is free. The meeting must finish by minute 1440.

Busy intervals may be unsorted and may overlap. If no valid interval exists, return -1.

Function

scheduleMeeting(schedules: int[][][], length: int) → int

Examples

Example 1

schedules = [[[60, 150], [180, 240]], [[0, 210], [360, 420]]]length = 120return = 240

The merged busy time covers minutes [0, 240). The first shared free interval therefore begins at minute 240, and at least 120 minutes remain before the next busy interval.

Example 2

schedules = [[[480, 510]], [[240, 330]], [[375, 400]]]length = 180return = 0

No employee is busy before minute 240, so the interval [0, 180) is available to everyone. The earliest valid start is 0.

Constraints

  • 1 <= schedules.length <= 100.
  • 0 <= schedules[i].length <= 100.
  • schedules[i][j].length == 2.
  • 0 <= schedules[i][j][0] < schedules[i][j][1] <= 1440.
  • 1 <= length <= 1440.

More Autodesk problems

See Autodesk hiring insights
public int scheduleMeeting(int[][][] schedules, int length) {
  // write your code here
}
schedules[[[60, 150], [180, 240]], [[0, 210], [360, 420]]]
length120
expected240
Checking account…