#3638
Maximum Balanced Shipments
specialist · 705 · lc medium +30 · 61.3% accepted · 78 likes · top 61%
Description
An integer array weight of length n represents parcels in a line. A contiguous subarray forms a balanced shipment when the weight of its last parcel is strictly less than the maximum weight within that shipment. Choose non-overlapping balanced shipments (each parcel belongs to at most one) to maximize the count. Return that maximum count.
Code
1
2
3