Weighted Job Scheduling Problem Statement

You have 'N' jobs, each with a start time, end time, and profit. Your task is to identify the maximum profit that can be earned by scheduling these jobs such that no two jobs overlap.

Input:
The first line contains an integer 'T' denoting the number of test cases. 
For each test case:
- The first line contains an integer 'N' denoting the number of jobs.
- The second line contains 'N' space-separated integers representing the start times of the jobs.
- The third line contains 'N' space-separated integers representing the end times of the jobs.
- The fourth line contains 'N' space-separated integers representing the profits of the jobs.
Output:
For each test case, output the maximum profit obtainable. Each result should be printed on a new line.

Example:

Input:
1 
4
1 2 3 3
3 5 4 5
50 10 40 70
Output:
120
Constraints:
  • 1 <= T <= 100
  • 1 <= N <= 3000
  • 1 <= Start[i] < End[i] <= 10^9
  • 1 <= Profit[i] <= 10^9
Note:

The start time of one job can be equal to the end time of another.

Follow-up:

Can you devise an algorithm that solves this problem in O(N*log(N)) time complexity?

AnswerBot
4mo

The Weighted Job Scheduling problem involves maximizing profit by scheduling non-overlapping jobs with given start times, end times, and profits.

  • Sort the jobs by end time in ascending order.

  • Initialize...read more

Help your peers!
Select
Add answer anonymously...

Atlassian Software Developer interview questions & answers

A Software Developer was asked Q. Implement the snake game.
A Software Developer was asked Q. How would you find the top k collections?
A Software Developer was asked Q. Find total size

Popular interview questions of Software Developer

A Software Developer was asked Q1. Implement the snake game.
A Software Developer was asked Q2. Find total size
A Software Developer was asked Q3. Design File System : You have given file size and collection in input 1 : get to...read more
Atlassian Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits