DEV Community

FORCHA
FORCHA

Posted on

mbs

To find the maximum number of balanced shipments, we need to identify the longest contiguous segment of parcels with an equal number of two types of parcels.
Solution By Steps
Step 1: Identify Parcel Types
Count the number of each type of parcel in the given list.
Step 2: Find Longest Contiguous Segment
Locate the longest contiguous segment where the counts of both types of parcels are equal.
Step 3: Calculate Maximum Balanced Shipments
Divide the length of the longest contiguous segment by 2 to determine the maximum number of balanced shipments.
Final Answer
The maximum number of balanced shipments is the length of the longest contiguous segment with an equal number of both types of parcels, divided by 2.

Top comments (0)