dp
with size n+1
(where n
is the number of boxes) and set all values to infinity, except dp[0]
which is set to 0.sum
, the starting index of the sliding window start
, and the number of different consecutive ports diff
.dp
array with the minimum number of trips needed to deliver boxes up to the current index.dp
array, which represents the minimum number of trips needed to deliver all boxes.