java.lang.Object
g1301_1400.s1335_minimum_difficulty_of_a_job_schedule.Solution

public class Solution extends Object
1335 - Minimum Difficulty of a Job Schedule.<p>Hard</p> <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p> <p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the <code>d</code> days. The difficulty of a day is the maximum difficulty of a job done on that day.</p> <p>You are given an integer array <code>jobDifficulty</code> and an integer <code>d</code>. The difficulty of the <code>i<sup>th</sup></code> job is <code>jobDifficulty[i]</code>.</p> <p>Return <em>the minimum difficulty of a job schedule</em>. If you cannot find a schedule for the jobs return <code>-1</code>.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/01/16/untitled.png" alt="" /></p> <p><strong>Input:</strong> jobDifficulty = [6,5,4,3,2,1], d = 2</p> <p><strong>Output:</strong> 7</p> <p><strong>Explanation:</strong> First day you can finish the first 5 jobs, total difficulty = 6.</p> <p>Second day you can finish the last job, total difficulty = 1.</p> <p>The difficulty of the schedule = 6 + 1 = 7</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> jobDifficulty = [9,9,9], d = 4</p> <p><strong>Output:</strong> -1</p> <p><strong>Explanation:</strong> If you finish a job per day you will still have a free day. you cannot find a schedule for the given jobs.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> jobDifficulty = [1,1,1], d = 3</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> The schedule is one job per day. total difficulty will be 3.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= jobDifficulty.length <= 300</code></li> <li><code>0 <= jobDifficulty[i] <= 1000</code></li> <li><code>1 <= d <= 10</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • minDifficulty

      public int minDifficulty(int[] jobDifficulty, int d)