Show problems as
Classic problem #252EasyArraySortingQuicksort

Meeting Rooms

Real-world version: Single Printer Feasibility
Tracked in this browser only
Read Meeting Rooms on LeetCode(opens in a new tab)

The statement here is our own: the same inputs, outputs and technique.

A print shop owns one plotter and has a day's worth of booked jobs. jobs[i] = [start_i, end_i] means job i occupies the plotter from minute start_i up to minute end_i.

The plotter can run one job at a time. A job that ends at the same minute another one starts is fine, since the sheet is already out of the tray.

Return true if every booked job can run on the single plotter, and false if two of them would need it at the same time. The jobs are given in booking order, which need not be time order.

Examples

Example 1

Input
jobs = [[9, 12], [3, 7], [13, 16]]
Output
true

In time order the jobs occupy minutes 3-7, 9-12 and 13-16, and no two of those spans share a minute.

Example 2

Input
jobs = [[2, 8], [6, 10]]
Output
false

Minutes 6, 7 and 8 are claimed by both jobs.

Example 3

Input
jobs = [[4, 6], [6, 9], [9, 11]]
Output
true

Each job starts exactly when the previous one ends, which is allowed.

Example 4

Input
jobs = [[0, 1], [5, 9], [6, 8]]
Output
false

The second and third jobs both claim minutes 6, 7 and 8.

Constraints

  • 0 <= jobs.length <= 10^4
  • jobs[i].length == 2
  • 0 <= start_i < end_i <= 10^6

The signature

The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.

Python
def can_attend_meetings(jobs: list[list[int]]) -> bool:
Java
public boolean canAttendMeetings(int[][] jobs)