Skip to content
Decoder

Maximum Profit in Job Scheduling

Hard

Problem

Job i runs from start_time[i] to end_time[i] and pays profit[i]. Choose a set of jobs with no two overlapping and return the maximum total profit. A job that ends at time X does not overlap one that starts at X.

Example 1

start_time = [1, 2, 3, 3], end_time = [3, 4, 5, 6], profit = [50, 10, 40, 70]

Example 2

  →  120   (jobs [1, 3] and [3, 6])

Example 3

start_time = [1, 1, 1], end_time = [2, 3, 4], profit = [5, 6, 4]

Example 4

  →  6

Constraints

  • 1 <= n <= 5 * 10^4, where n is the number of jobs
  • 1 <= start_time[i] < end_time[i] <= 10^9
  • 1 <= profit[i] <= 10^4

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.