Dynamic Programming Interview Questions: Maximum Profit in Job Scheduling

Dynamic Programming Interview Questions: Maximum Profit in Job Scheduling

Find the maximum profit you can make from a given list of jobs. Dynamic Programming Interview Questions: Maximum Profit in Job Scheduling. Today’s problem is challenging — a classic problem you may have seen in your algorithms courses. For those of you who’ve already seen it, this will serve as a great comprehensive review. If it’s new to you, take your time to digest it all.

Today’s problem is challenging — a classic problem you may have seen in your algorithms courses. For those of you who’ve already seen it, this will serve as a great comprehensive review. If it’s new to you, take your time to digest it all.

Let’s take a look at the problem.


We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i].

You’re given the startTimeendTime and profit arrays. You need to output the maximum profit you can take, such that there are no two jobs in the subset with an overlapping time range.

If you choose a job that ends at time x you will be able to start another job that starts at time x.

Example 1

Image for post

  • Input: startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70]
  • Output: 120
  • Explanation: The subset chosen is the first and fourth job.
  • Time range [1–3]+[3–6] , we get profit of 120 = 50 + 70.

Example 2

Image for post

  • Input: startTime = [1,2,3,4,6], endTime = [3,5,10,6,9], profit = [20,20,100,70,60]
  • Output: 150
  • Explanation: The subset chosen is the first, fourth and fifth job.
  • Profit obtained 150 = 20 + 70 + 60.

Example 3

Image for post

Input: startTime = [1,1,1], endTime = [2,3,4], profit = [5,6,4]

Output: 6


Before we get into solving this problem, let’s consider a simpler version of it.

Suppose the profit for all jobs is equal. Essentially, this means that completing as many jobs as possible will be our optimal solution (it really doesn’t matter what job you take as long as it’s a job). Does this sound familiar? Bingo — it sounds like a greedy algorithm type of problem!

interview software-development interview-questions python programming

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Top 130 Android Interview Questions - Crack Technical Interview Now!

Top Android Interview Questions & Answers from Beginner to Advanced level. Get ready to crack your next android interview with these android interview questions

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.

Hire Python Developers

Are you looking for experienced, reliable, and qualified Python developers? If yes, you have reached the right place. At **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, our full-stack Python development services...

Hire Python Developers India

Looking to build robust, scalable, and dynamic responsive websites and applications in Python? At **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, we constantly endeavor to give you exactly what you need. If you need to...

Python Quickfire Interview Questions

Python’s popularity is increasing by the day as many people are seeing merit in learning a language that is both popular and widely used. Python programming language shines when used in disciplines such as data science, machine learning web and API development, and many more. With this mind, I thought it would be helpful to create an overview of some commonly asked Python questions and answers for data scientists and software engineers who may be heading into job interviews where knowledge of the language is key.