Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Capacity To Ship Packages Within D Days
Bookmark
Linear Search on Capacity
Binary Search on Answer
Input
Example 1
Example 2
Example 3
Equal weights
Heavy first
Custom
weights
=
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
,
days
=
5
?
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
?
?
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
?
Range: [10, 55]
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
?
Testing capacity: 10
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
Days: 7/5
7 > 5: Not feasible
Testing capacity: 11
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
Days: 6/5
6 > 5: Not feasible
Testing capacity: 12
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
Days: 6/5
6 > 5: Not feasible
Testing capacity: 13
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
Days: 6/5
6 > 5: Not feasible
Testing capacity: 14
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
Days: 6/5
6 > 5: Not feasible
Answer: 15
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
5 <= 5: Feasible
algo
master
.
io
Step:
Ship packages [1,2,3,4,5,6,7,8,9,10] within 5 days
0 / 7
Input
Example 1
Example 2
Example 3
Equal weights
Heavy first
Custom
weights
=
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
,
days
=
5
0 / 7
algo
master
.
io
Step:
Ship packages [1,2,3,4,5,6,7,8,9,10] within 5 days