InferenceAI

Enter at least two characters to search.

Start free

Deadline Job Profit

mediumGreedy & Intervals25 min25 XP

Each job takes one unit of time, has a deadline (it must finish by that time slot, slots start at 1) and a profit. Return [jobs_done, total_profit] for the schedule with maximum total profit.

Examples

EXAMPLE WALKTHROUGHclassic

A guided view of the published example, not a trace of your code.

INPUT[[4,1,1,1],[20,10,40,30]]
TASKdeadline_job_profit()
EXPECTED OUTPUT[2,60]

Start with the input values shown in this example.

Example 1 of 3

Input: deadline = [4,1,1,1], profit = [20,10,40,30]

Output: [2,60]

Explanation: classic

Input: deadline = [2,1,2,1,1], profit = [100,19,27,25,15]

Output: [2,127]

Explanation: five jobs

Input: deadline = [1], profit = [5]

Output: [1,5]

Explanation: single

Hint 1

Process jobs by profit, highest first.

Hint 2

Put each job in the latest free slot at or before its deadline.

Topics

DSAGreedy & IntervalsPython