
• Start Time, denoting the start time of the job.
• End Time, denoting the end time of the job.
• Profit associated with the job.
Let there be three jobs ‘A’, ‘B’, and ‘C’-
• Start time, End time and profit associated with job ‘A’ being 1, 1 and 30.
• Start time, End time and profit associated with job ‘B’ being 1, 2 and 40.
• Start time, End time and profit associated with job ‘C’ being 3, 4 and 30.
We will perform job ‘B’ at time t = 1 and job ‘C’ at time t = 3. The total profit will be 70. There is no other sequence of jobs which can fetch us a better overall profit.
The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the test case follows.
The first line of each test case contains a single space-separated integers ‘N’, denoting the total number of jobes
The next ‘N’ lines contain three space separated integers, start[i], end[i] and profit[i] denoting the start time, end time and the profit associated with the i-th job.
For each test case, print the maximum profit after scheduling all the jobs in an optimal manner.
Output for each test case will be printed in a new line.
Note: You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 10^3
1 <= start[i] <= 10^5
1 <= end[i] <=10^5
start[i] <= end[i]
1 <= profit[i] <= 10^5
Time Limit: 1sec
We can also use dynamic programming to solve this problem. We will sort all the jobs according to their finish times. We will then use an iterative dp approach to find the maximum profit.
The algorithm will be-
Min Stack
Min Stack
Min Stack
Min Stack
Min Stack
Min Stack
Min Stack
Min Stack
Min Stack
Min Stack
Check Palindrome
Check Palindrome
Left Rotate an Array by One
Left Rotate an Array by One
Left Rotate an Array by One
Left Rotate an Array by One
Left Rotate an Array by One
Left Rotate an Array by One
Beautiful Number
Max tasks in the given Budget