Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 076c2d6

Browse files
committed
Create README - LeetHub
1 parent 8129eff commit 076c2d6

File tree

1 file changed

+49
-0
lines changed
  • 1011-capacity-to-ship-packages-within-d-days

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<h2><a href="https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/">1011. Capacity To Ship Packages Within D Days</a></h2><h3>Medium</h3><hr><div><p>A conveyor belt has packages that must be shipped from one port to another within <code>days</code> days.</p>
2+
3+
<p>The <code>i<sup>th</sup></code> package on the conveyor belt has a weight of <code>weights[i]</code>. Each day, we load the ship with packages on the conveyor belt (in the order given by <code>weights</code>). We may not load more weight than the maximum weight capacity of the ship.</p>
4+
5+
<p>Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within <code>days</code> days.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre><strong>Input:</strong> weights = [1,2,3,4,5,6,7,8,9,10], days = 5
11+
<strong>Output:</strong> 15
12+
<strong>Explanation:</strong> A ship capacity of 15 is the minimum to ship all the packages in 5 days like this:
13+
1st day: 1, 2, 3, 4, 5
14+
2nd day: 6, 7
15+
3rd day: 8
16+
4th day: 9
17+
5th day: 10
18+
19+
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.
20+
</pre>
21+
22+
<p><strong class="example">Example 2:</strong></p>
23+
24+
<pre><strong>Input:</strong> weights = [3,2,2,4,1,4], days = 3
25+
<strong>Output:</strong> 6
26+
<strong>Explanation:</strong> A ship capacity of 6 is the minimum to ship all the packages in 3 days like this:
27+
1st day: 3, 2
28+
2nd day: 2, 4
29+
3rd day: 1, 4
30+
</pre>
31+
32+
<p><strong class="example">Example 3:</strong></p>
33+
34+
<pre><strong>Input:</strong> weights = [1,2,3,1,1], days = 4
35+
<strong>Output:</strong> 3
36+
<strong>Explanation:</strong>
37+
1st day: 1
38+
2nd day: 2
39+
3rd day: 3
40+
4th day: 1, 1
41+
</pre>
42+
43+
<p>&nbsp;</p>
44+
<p><strong>Constraints:</strong></p>
45+
46+
<ul>
47+
<li><code>1 &lt;= days &lt;= weights.length &lt;= 5 * 10<sup>4</sup></code></li>
48+
<li><code>1 &lt;= weights[i] &lt;= 500</code></li>
49+
</ul></div>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /