1335. Minimum Difficulty of a Job Schedule Hard
1/**
2 * [1335] Minimum Difficulty of a Job Schedule
3 *
4 * You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i^th job, you have to finish all the jobs j where 0 <= j < i).
5 * You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.
6 * You are given an integer array jobDifficulty and an integer d. The difficulty of the i^th job is jobDifficulty[i].
7 * Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.
8 *
9 * Example 1:
10 * <img alt="" src="https://assets.leetcode.com/uploads/2020/01/16/untitled.png" style="width: 365px; height: 370px;" />
11 * Input: jobDifficulty = [6,5,4,3,2,1], d = 2
12 * Output: 7
13 * Explanation: First day you can finish the first 5 jobs, total difficulty = 6.
14 * Second day you can finish the last job, total difficulty = 1.
15 * The difficulty of the schedule = 6 + 1 = 7
16 *
17 * Example 2:
18 *
19 * Input: jobDifficulty = [9,9,9], d = 4
20 * Output: -1
21 * Explanation: If you finish a job per day you will still have a free day. you cannot find a schedule for the given jobs.
22 *
23 * Example 3:
24 *
25 * Input: jobDifficulty = [1,1,1], d = 3
26 * Output: 3
27 * Explanation: The schedule is one job per day. total difficulty will be 3.
28 *
29 *
30 * Constraints:
31 *
32 * 1 <= jobDifficulty.length <= 300
33 * 0 <= jobDifficulty[i] <= 1000
34 * 1 <= d <= 10
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule/
40// discuss: https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn min_difficulty(job_difficulty: Vec<i32>, d: i32) -> i32 {
46 0
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_1335() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.