Job Scheduling Problem
You are provided with a list of jobs, where each job has a specific deadline and profit. The goal is to schedule these jobs such that the total profit is maximized. Each job requires exactly one unit of time and only one job can be scheduled at any given time.
Explanation:
Schedule the jobs by maximizing the total profit, ensuring that each job is completed before its respective deadline. Jobs can only be scheduled at integer times starting from 1.
Input:
The first line of the input contains an integer ‘T’ representing the number of test cases. Each test case begins with an integer ‘N’ denoting the number of jobs. The next ‘N’ lines contain two space-separated integers: deadline[i]
and profit[i]
for the i-th job.
Output:
For each test case, output the maximum profit achievable by scheduling the jobs optimally. Each result should be printed on a new line.
Example:
Jobs: A (Profit: 20, Deadline: 1), B (Profit: 30, Deadline: 2), C (Profit: 40, Deadline: 2)
Scheduled Order: C at t=1, B at t=2
Total Profit: 70
Constraints:
1 <= T <= 5
1 <= N <= 10^3
1 <= deadline[i] <= N
1 <= profit[i] <= 10^9
- Time Limit: 1 sec
Note:
You do not need to print anything; it has already been implemented. Focus on completing the function provided.
Be the first one to answer
Add answer anonymously...
Top Atlassian Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Atlassian Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app