Job Sequencing Problem
Medium Accuracy: 48.94% Submissions: 43368 Points: 4

Given a set of N jobs where each jobi has a deadline and profit associated with it. Each job takes 1 unit of time to complete and only one job can be scheduled at a time. We earn the profit if and only if the job is completed by its deadline. The task is to find the number of jobs done and the maximum profit.

Note: Jobs will be given in the form (Jobid, Deadline, Profit) associated with that Job.

Example 1:

N = 4
Jobs = {(1,4,20),(2,1,10),(3,1,40),(4,1,30)}
2 60
Job1 and Job3 can be done with
maximum profit of 60 (20+40).

Example 2:

N = 5
Jobs = {(1,2,100),(2,1,19),(3,2,27),
2 127
2 jobs can be done with
maximum profit of 127 (100+27).

Your Task :
You don't need to read input or print anything. Your task is to complete the function JobScheduling() which takes an integer N and an array of Jobs(Job id, Deadline, Profit) as input and returns the count of jobs and maximum profit.

Expected Time Complexity: O(NlogN)
Expected Auxilliary Space: O(N)

1 <= N <= 105
1 <= Deadline <= 100
1 <= Profit <= 500

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Job Sequencing Problem

Output Window