All problems
0383EasyArraySortingQuicksort

Single Printer Feasibility

Tracked in this browser only
Write code

Trains the technique from

LeetCode 252Meeting Rooms

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

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 is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

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