Skip to main content

Maximum Profit in Job Scheduling

Given startTime, endTime, and profit arrays for n jobs Return the maximum profit you can take such that no two jobs overlap If a job ends at time X, another job can start at time X Example: startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70] => 120

Given three equally sized, non-empty integer arrays startTime, endTime, and profit, return the maximum total profit obtainable by selecting jobs whose time intervals do not overlap. Job i starts at startTime[i], ends at endTime[i], and earns profit[i], with startTime[i] < endTime[i] and positive profit. A job ending at time X may be followed immediately by a job starting at X. For example, startTime = [1,2,3,3], endTime = [3,4,5,6], and profit = [50,10,40,70] return 120.

Examples

You write

job_scheduling(start_time: List[int], end_time: List[int], profit: List[int])

  1. Example 1

    Input
    startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70]
    returns
    120
  2. Example 2

    Input
    startTime = [1,2,3,4,6], endTime = [3,5,10,6,9], profit = [20,20,100,70,60]
    returns
    150

The pattern behind it

Arrays & Hashing

I reach for it when

  • You catch yourself scanning the array again for every element.
  • The problem asks about duplicates, pairs, counts or groups.

Say this before you type. Say what the key is and what the value remembers, before you write the loop.

All 127 Arrays & Hashing problems

Binary Search

I reach for it when

  • The input is sorted, or sorted and then rotated.
  • You want a boundary: the first or last place something is true.

Say this before you type. Say the yes-or-no question, and which side each answer throws away.

All 19 Binary Search problems

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit. The editor and Run stay open without an account. Anyone can open the editor and run their code.

1Maximum Profit Job Schedulinghard

Prep guides that list this problem

Our company tags come from public interview write-ups. None of these is a confirmed question.