Tap here to switch tabs
Problem
Submissions

Problem: Maximum Balanced Shipments

med
30 min
Try to solve the Maximum Balanced Shipments problem.

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

med
30 min
Try to solve the Maximum Balanced Shipments problem.

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