Tap here to switch tabs
Problem
Submissions

Problem: Maximum Balanced Shipments

Maximum Balanced Shipments asks for the greatest number of disjoint contiguous shipments in a parcel-weight array, where each shipment’s last weight is below its maximum.

Statement

Given an integer array weight of size n, representing the weights of parcels placed in a row.

A shipment is defined as a contiguous subarray of parcels. A shipment is considered balanced if the weight of its last parcel is strictly less than the maximum parcel weight within that shipment.

Return the maximum number of disjoint balanced shipments that can be formed from weight.

Constraints:

  • 2≤2 \leq n ≤105\leq 10^5

  • 1≤1 \leq weight[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Balanced Shipments

Maximum Balanced Shipments asks for the greatest number of disjoint contiguous shipments in a parcel-weight array, where each shipment’s last weight is below its maximum.

Statement

Given an integer array weight of size n, representing the weights of parcels placed in a row.

A shipment is defined as a contiguous subarray of parcels. A shipment is considered balanced if the weight of its last parcel is strictly less than the maximum parcel weight within that shipment.

Return the maximum number of disjoint balanced shipments that can be formed from weight.

Constraints:

  • 2≤2 \leq n ≤105\leq 10^5

  • 1≤1 \leq weight[i] ≤109\leq 10^9