Maximizing revenue with constraints

Question

You are given an array of jobs. Each element in the array has the following attributes:

  • Start Time: Time at which the job starts
  • End Time: Time at which the job ends
  • Revenue: Value associated with the job

For example, if [1, 2, 50] is an element in an array of jobs, then:

  • 1 = start time
  • 2 = end time
  • 50 = revenue

Given this information, write a function that finds the maximum revenue for a set of jobs. You must ensure that no two jobs selected have times that overlap (e.g. the start time of one job does not occur before the end time of another).

For example:

input: jobs = [[1, 2, 50], [1, 2, 100], [7, 25, 100], [6, 21, 45], [3, 50, 200], [7, 50, 400]]
output: "Optimal profit for this set of jobs is: 500"
# Note that two jobs that were selected here, [1, 2, 100] and [7, 50, 400]

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now