Skip to content

Maximum Profit in Job Scheduling

HardIntervals
Decode it first. Clues, constraints, pattern and plan before any code.

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.

start_time = [1, 2, 3, 3], end_time = [3, 4, 5, 6], profit = [50, 10, 40, 70]
  →  120   (jobs [1, 3] and [3, 6])
 
start_time = [1, 1, 1], end_time = [2, 3, 4], profit = [5, 6, 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