Maximum Balanced Shipments

Asked at Amazon · Coding Questions · Difficulty: Medium

Parcels have weights `weights`. A shipment is a contiguous segment; it is *balanced* if the last parcel's weight is **not** the maximum weight in that segment. Partition (a prefix-disjoint selection of) parcels into the maximum number of balanced shipments and return that count (0 if none possible).

Loading the problem…