Medium
,Array
,Binary Search
1011. Capacity To Ship Packages Within D Days
A conveyor belt has packages that must be shipped from one port to another within days
days.
The ith 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.
Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within days
days.
Example 1:
Example 2:
Example 3:
Constraints:
days
<= weights.length
<= 5 * 104weights[i]
<= 500每日需運輸的最小重量至少會是陣列的最大值,最大重量則是陣列的總和
對這之間的重量去做 Binary Search,看看能不能在天數內搬運完所有的貨物
Ron ChenWed, Feb 22, 2022
Time: 確認 個element最多 次
Extra Space:
XD Feb 22, 2023