Maximum Profit in Job Scheduling
Given jobs described by startTime[i], endTime[i], and profit[i], select a subset of non-overlapping jobs maximizing total profit. Two jobs are compatible if one ends at or before the other starts (a job ending at time t and another starting at t may both be taken). Return the maximum profit.
Open official problem prompt ↗Pick a set of time-disjoint jobs that earns the most money, where longer or later jobs may or may not be worth skipping cheaper earlier ones.
A freelancer with one desk choosing gigs from a calendar. Each accepted gig blocks its time slot. For any gig you consider, you ask: what is the most I could have earned from gigs that were already finished by the time this one starts, plus this gig's pay?
- Input
- startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70]
- Output
- 120
- Why
- Take job 0 (1->3, 50) and job 3 (3->6, 70); they do not overlap and sum to 120.
1 <= startTime.length == endTime.length == profit.length <= 5 * 10^41 <= startTime[i] < endTime[i] <= 10^91 <= profit[i] <= 10^4