You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A conveyor belt has packages that must be shipped from one port to another within D days.
3
+
4
+
The i-th package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.
5
+
6
+
Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within D days.
7
+
8
+
9
+
10
+
Example 1:
11
+
12
+
Input: weights = [1,2,3,4,5,6,7,8,9,10], D = 5
13
+
Output: 15
14
+
Explanation:
15
+
A ship capacity of 15 is the minimum to ship all the packages in 5 days like this:
16
+
1st day: 1, 2, 3, 4, 5
17
+
2nd day: 6, 7
18
+
3rd day: 8
19
+
4th day: 9
20
+
5th day: 10
21
+
22
+
Note that the cargo must be shipped in the order given, so using a ship of capacity 14 and splitting the packages into parts like (2, 3, 4, 5), (1, 6, 7), (8), (9), (10) is not allowed.
23
+
Example 2:
24
+
25
+
Input: weights = [3,2,2,4,1,4], D = 3
26
+
Output: 6
27
+
Explanation:
28
+
A ship capacity of 6 is the minimum to ship all the packages in 3 days like this:
Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays.
3
+
4
+
Note:
5
+
If n is the length of array, assume the following constraints are satisfied:
6
+
7
+
1 ≤ n ≤ 1000
8
+
1 ≤ m ≤ min(50, n)
9
+
Examples:
10
+
11
+
Input:
12
+
nums = [7,2,5,10,8]
13
+
m = 2
14
+
15
+
Output:
16
+
18
17
+
18
+
Explanation:
19
+
There are four ways to split nums into two subarrays.
20
+
The best way is to split it into [7,2,5] and [10,8],
21
+
where the largest sum among the two subarrays is only 18.
Copy file name to clipboardExpand all lines: README.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Python solution of problems from [LeetCode](https://leetcode.com/).
8
8
| # | Title | Solution | Difficulty |
9
9
|---| ----- | -------- | ---------- |
10
10
|1002|[Find Common Characters](https://leetcode.com/problems/find-common-characters)|[Python](./1000-1100q/1002.py)|Easy|
11
+
|1014|[Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/)|[Python](./1000-1100q/1014.py)| Medium|
11
12
12
13
##### [Problems 900-1000](./900-1000q/)
13
14
| # | Title | Solution | Difficulty |
@@ -29,6 +30,11 @@ Python solution of problems from [LeetCode](https://leetcode.com/).
29
30
|977|[Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array/)|[Python](./900-1000q/977.py)|Easy|
30
31
31
32
33
+
##### [Problems 400-500](./400-500q/)
34
+
| # | Title | Solution | Difficulty |
35
+
|---| ----- | -------- | ---------- |
36
+
|410|[Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum/)|[Python](./400-500q/410.py)|Hard|
0 commit comments