Schedule Min Difficulty Problem

Schedule Min Difficulty Problem — ExecCode Hard DSA Practice

Solve the Schedule Min Difficulty problem on ExecCode. Free online hard DSA practice in DP. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You must finish n jobs in order over d days. Each day you do a non-empty contiguous prefix of remaining jobs. A day's difficulty is the max job that day. Minimize the sum of day difficulties. If you have fewer jobs than days, return -1. Amazon OA hard. Return the minimum sum, or -1. You are given: jobdifficulty — jobs in order d — number of days Return integer or -1. d = 1 means the answer is max(jobdifficulty).

Examples

Input {'jobdifficulty': [6, 5, 4, 3, 2, 1], 'd': 2}; Output 7. Input {'jobdifficulty': [9, 9, 9], 'd': 4}; Output -1. Input {'job_difficulty': [1, 1, 1], 'd': 3}; Output 3

Constraints

Order cannot be changed Every day must take at least one job

Practice Schedule Min Difficulty free on ExecCode. Browse DSA problems, topic map, and placement guides.